示例#1
0
文件: sample_lsag.py 项目: np/Py-EC
def get_signature_size( signature ):
    public_keys, message, c_0, ss, Y_tilde = signature
    # Each public key is 64 bytes (32 bytes per coordinate)
    size = 64 * len( public_keys )
    size += len( ECHelper.int2bin( c_0 ) )
    size += sum( map( lambda s: len( ECHelper.int2bin( s ) ), ss ) )
    # Y_tilde is also a point, which again requires 64 bytes
    size += 64
    return size
示例#2
0
def get_signature_size( signature ):
    public_keys, message, c_0, ss, Y_tilde = signature
    # Each public key is 64 bytes (32 bytes per coordinate)
    size = 64 * len( public_keys )
    size += len( ECHelper.int2bin( c_0 ) )
    size += sum( map( lambda s: len( ECHelper.int2bin( s ) ), ss ) )
    # Y_tilde is also a point, which again requires 64 bytes
    size += 64
    return size
示例#3
0
 def find_point_try_and_increment(self, x):
     if self.field_type != 'prime':
         raise Exception( "find_point_try_and_increment is only implemented for curves over prime fields")
     
     ## HUSK AT FREE BIGNUMS
     found = False
     x -= 1
     while not found:
         x += 1
         f_x = self.f( x )
         y = ECHelper.modular_sqrt( f_x, self.p )
         if y != 0:
             return ec_point.Point( self, x=x, y=y )
示例#4
0
 def __init__(self, os_bn=None,decval=None,binval=None):
     """
     Constructs a new BN object
     and fills it with the value given.
     """
     if os_bn is not None:
         self.bn = os_bn
         self.__created_bn = False
     else:
         self.bn = OpenSSL.BN_new()
         self.__created_bn = True
         if decval is None and binval is None:
             decval = 0
             
         if decval is not None:
             binval = ECHelper.int2bin( decval )
             
         if binval is not None:
             OpenSSL.BN_bin2bn( binval, len( binval ), self.bn )
示例#5
0
    def __init__(self, os_bn=None, decval=None, binval=None):
        """
        Constructs a new BN object
        and fills it with the value given.
        """
        if os_bn is not None:
            self.bn = os_bn
            self.__created_bn = False
        else:
            self.bn = OpenSSL.BN_new()
            self.__created_bn = True
            if decval is None and binval is None:
                decval = 0

            if decval is not None:
                binval = ECHelper.int2bin(decval)

            if binval is not None:
                OpenSSL.BN_bin2bn(binval, len(binval), self.bn)
示例#6
0
 def encode_binary(self):
     return ECHelper.int2bin(self.x) + ECHelper.int2bin(self.y)
示例#7
0
 def encode_binary(self):
     return ECHelper.int2bin( self.x ) + ECHelper.int2bin( self.y )