ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 28 Nov 2016 22:46:08 -0600Getting code dumped error in sage code for weil-pairing ?http://ask.sagemath.org/question/35770/getting-code-dumped-error-in-sage-code-for-weil-pairing/ I have been trying to run a sage code for doing weil-pairing which gives the following error message:
' */usr/lib/sagemath/local/bin/sage-python: line 2: 15172 **Segmentation fault (core dumped)** sage -python "$@"* '
I tried sage versions 7.2, 7.3, and 7.4 but still getting same error. I am using Ubuntu 14.04. But it works in another system running Ubuntu. Someone please help.
# Weil Pairing Example
# Example 5.43 in IMC
# E: y^2 = x^3 + 30x + 34 mod 631
p = 631
a = 30
b = 34
E = EllipticCurve(GF(p), [a, b])
print E
P = E((36, 60))
Q = E((121, 387))
n = 5
S = E((0, 36))
print "P =", P.xy()
print "Q =", Q.xy()
print "#P = #Q =", n
var('x y')
def g(P, Q):
(x_P, y_P) = P.xy()
(x_Q, y_Q) = Q.xy()
if x_P == x_Q and y_P + y_Q == 0:
return x - x_P
if P == Q:
slope = (3 * x_P^2 + a)/(2 * y_P)
else:
slope = (y_P - y_Q)/(x_P - x_Q)
return (y - y_P - slope * (x - x_P))/(x + x_P + x_Q - slope^2)
def miller(m, P):
m = bin(m)[3:]
n = len(m)
T = P
f = 1
for i in range(n):
f = f^2 * g(T, T)
T = T + T
if int(m[i]) == 1:
f = f * g(T, P)
T = T + P
return f
def eval_miller(P, Q):
f = miller(n, P)
(x1, y1) = Q.xy()
return f(x = x1, y = y1)
def weil_pairing(P, Q, S):
num = eval_miller(P, Q+S)/eval_miller(P, S)
den = eval_miller(Q, P-S)/eval_miller(Q, -S)
return (num/den)
e = weil_pairing(P, Q, S)
print "e(P, Q) =", e
# e^n = 1
print "e(P, Q)^n =", e^n
P3 = P * 3
Q4 = Q * 4
e12 = weil_pairing(P3, Q4, S)
print "[3]P =", P3.xy()
print "[4]Q =", Q4.xy()
print "e([3]P, [4]Q) =", e12
print "e(P, Q)^12 =", e^12SP HarishMon, 28 Nov 2016 22:46:08 -0600http://ask.sagemath.org/question/35770/how to remove duplicate elements in a listhttp://ask.sagemath.org/question/7696/how-to-remove-duplicate-elements-in-a-list/From a list L = ([1,2,3,4],[3,5,6,7],[7,8,9,10],[1,2,3.4])
remove duplicate sets here [1,2,3,4] has occurred twice and put only one
making L = ([1,2,3,4],[3,5,6,7],[7,8,9,10])sriramFri, 17 Sep 2010 02:23:50 -0500http://ask.sagemath.org/question/7696/collection of setshttp://ask.sagemath.org/question/7695/collection-of-sets/How to create a collection of sets and how find its subcollections of specified sizesriramFri, 17 Sep 2010 01:38:04 -0500http://ask.sagemath.org/question/7695/collection of setshttp://ask.sagemath.org/question/7699/collection-of-sets/How to create a collection of sets and how find its subcollections of specified size
ordered pairs for example say a collection of set {[1,2,3],[3,2,4],[1,2,4]}
subcollection of size 2
{[1,2,3],[3,2,4]}
{[3,2,4],[1,2,3]}
{[3,2,4],[1,20,4]}
{[1,20,4],[3,2,4]}
{[1,2,3],[1,2,4]}
{[1,2,4],[1,2,3]}
Is it possible to do this program below without finding all subsets
sage: s = set([1,3,"two"]) # make a set from a list of items
sage: t = list(subsets(s)); t # this is the list of all subsets of s
[[], [1], [3], [1, 3], ['two'], [1, 'two'], [3, 'two'], [1, 3, 'two']]
sage: for x in subsets(s): # subsets(s) is an iterator, so you can loop through it
....: if len(x) == 2: # and extract items of a specified length
....: print x
....:
[1, 3]
[1, 'two']
[3, 'two']
sriramFri, 17 Sep 2010 23:00:14 -0500http://ask.sagemath.org/question/7699/sub list like subsetshttp://ask.sagemath.org/question/7693/sub-list-like-subsets/how to take lists of size from a list like subsets of size
example L = ([1,2,3,4],[3,5,6,7],[7,8,9,10])
From the above list find sublists of size 2
([1,2,3,4],[3,5,6,7])
([1,2,3,4],[7,8,9,10])
([3,5,6,7],[7,8,9,10])
subsets can also be size 3,4,5 as specifiedsriramThu, 16 Sep 2010 23:08:08 -0500http://ask.sagemath.org/question/7693/