コード例 #1
0
def test_Sign_Verification():

    msg = 'Hello, I am a message, sign me'
    for x in range(100):
        # Generate pair of keys in PEM format
        pub_privKey = Nakasendo.ECKey256K1()
        pub_key = pub_privKey.pubKey

        # Sign message with private Key
        rSig, sSig = pub_privKey.sign(msg)

        # Verify message's signature with public key
        verify_ok = Nakasendo.verify(msg, pub_key, rSig, sSig)
        assert verify_ok, "Test failed"
コード例 #2
0
ファイル: TestNakasendo.py プロジェクト: hilzlee/nakasendo-1
    print(mykey)
    print("derive a public key..")
    myderivedKey = mykey.derivePublicKey("Using this message")
    print(myderivedKey)
    shares = mykey.SplitKey(3, 6)

    print('And now recover')
    recoveredKey = Nakasendo.ECKey256K1()
    recoveredKey.RecoverKey(shares)
    print(recoveredKey)

    #Sign a msessage
    msg = 'The quick brown fox jumped over the lazy dog'
    sig = mykey.sign(msg)
    print(sig)
    verifyIt = Nakasendo.verify(msg, mykey.pubKey, sig[0], sig[1])
    if (verifyIt == True):
        print('msg verified')

    #generate a shared secret

    AliceKey = Nakasendo.ECKey256K1()
    BobsKey = Nakasendo.ECKey256K1()

    msgFromBob = BobsKey.CalculateSharedSecret(AliceKey.pubKey)
    msgFromAlice = AliceKey.CalculateSharedSecret(BobsKey.pubKey)

    print(msgFromBob)
    print(msgFromAlice)

    # Demo loading creating PEM file with Encryption and passphrase
コード例 #3
0
ファイル: verifyTest.py プロジェクト: hilzlee/nakasendo-1
    # create an ECPoint
    pt = Nakasendo.ECPoint()
    pt.value = pubKeyStr
    #print(pt.GetAffineCoOrdinates())

    coords = pt.GetAffineCoOrdinates()

    pempubkey = Nakasendo.pubKeyHexPtasPem(coords[0], coords[1])
    print(pempubkey)
    print('verify the pem format')
    pubKeyStrValidate = Nakasendo.pubKeyPEMasHex(pempubkey, True)
    #print(pubKeyStrValidate)
    # get the affine co-ordinates
    # get pem format

    valPem = Nakasendo.verify(message, pempubkey, sigRStr, sigSStr)
    if (valPem == True):
        print(
            'Calculated signature verified with calculated PEM & call to verify'
        )
    else:
        print('Failed to verify with calculated PEM')

    val = Nakasendo.verifyPubKeyHex(message, pubKeyStr, sigRStr, sigSStr)
    if (val == True):
        print('Calculated signature verified via Nakasendo verify')
    else:
        print('Failed to verify with Nakasendo verify')

    hmMessage = Nakasendo.hash256(
        message=message,