test/functional/test_framework/key.py
def sign_schnorr(self, msg32):
        """Create Schnorr signature (BIP-Schnorr convention)."""
        assert self.valid
        assert len(msg32) == 32

        pubkey = self.get_pubkey()
        assert pubkey.is_valid

        k = random.randrange(1, SECP256K1_ORDER)

        R = SECP256K1.affine(SECP256K1.mul([(SECP256K1_G, k)]))

        if jacobi_symbol(R[1], SECP256K1.p) == -1:
            k = SECP256K1_ORDER - k

        Rx = R[0].to_bytes(32, 'big')
        e = int.from_bytes(
            hashlib.sha256(
                Rx +
                pubkey.get_bytes() +
                msg32).digest(),
            'big')
        s = (k + e * int.from_bytes(self.get_bytes(), 'big')) % SECP256K1_ORDER
        sig = Rx + s.to_bytes(32, 'big')

        assert pubkey.verify_schnorr(sig, msg32)
        return sig
Create Schnorr signature (BIP-Schnorr convention).
Create Schnorr signature (BIP-Schnorr convention).
Create Schnorr signature ( BIP - Schnorr convention ) .
def sign_schnorr(self, msg32):
        assert self.valid
        assert len(msg32) == 32
        pubkey = self.get_pubkey()
        assert pubkey.is_valid
        k = random.randrange(1, SECP256K1_ORDER)
        R = SECP256K1.affine(SECP256K1.mul([(SECP256K1_G, k)]))
        if jacobi_symbol(R[1], SECP256K1.p) == -1:
            k = SECP256K1_ORDER - k
        Rx = R[0].to_bytes(32, 'big')
        e = int.from_bytes(
            hashlib.sha256(
                Rx +
                pubkey.get_bytes() +
                msg32).digest(),
            'big')
        s = (k + e * int.from_bytes(self.get_bytes(), 'big')) % SECP256K1_ORDER
        sig = Rx + s.to_bytes(32, 'big')
        assert pubkey.verify_schnorr(sig, msg32)
        return sig
def sign_schnorr ( self , msg32 ) : assert self . valid assert len ( msg32 ) == 32 pubkey = self . get_pubkey ( ) assert pubkey . is_valid k = random . randrange ( 1 , SECP256K1_ORDER ) R = SECP256K1 . affine ( SECP256K1 . mul ( [ ( SECP256K1_G , k ) ] ) ) if jacobi_symbol ( R [ 1 ] , SECP256K1 . p ) == - 1 : k = SECP256K1_ORDER - k Rx = R [ 0 ] . to_bytes ( 32 , 'big' ) e = int . from_bytes ( hashlib . sha256 ( Rx + pubkey . get_bytes ( ) + msg32 ) . digest ( ) , 'big' ) s = ( k + e * int . from_bytes ( self . get_bytes ( ) , 'big' ) ) % SECP256K1_ORDER sig = Rx + s . to_bytes ( 32 , 'big' ) assert pubkey . verify_schnorr ( sig , msg32 ) return sig
Create Schnorr signature (BIP-Schnorr convention).
Create Schnorr signature ( BIP - Schnorr convention ) .
"""Create Schnorr signature (BIP-Schnorr convention)."""
self
msg32