Beispiel #1
0
    f = open("testPem.pem", "r")
    pemStr = f.read()
    f.close()
    os.remove("testPem.pem")

    newKey.FromEncryptedPEMStr(pemStr, passphrase)
    # this will throw:
    #newKey.FromEncryptedPEMStr( pemStr, "This is not a correct passphrase" )

    print("public key = ", newKey.pubKey)
    print("private key = ", newKey.priKey)

    # generate a derived pub key PEM & convert to HEX (compressed & uncompressed)
    pubkeyPEM = BobsKey.derivePublicKey(msg)
    print("Derived pub key PEM = ", pubkeyPEM)
    derivedPubKeyHex = Nakasendo.pubKeyPEMasHex(pubkeyPEM)
    print("Dervied pub key hex uncompressed = ", derivedPubKeyHex)

    derivedPubKeyHex = Nakasendo.pubKeyPEMasHex(pubkeyPEM, True)
    print("Dervied pub key hex uncompressed = ", derivedPubKeyHex)
    print(
        'convert the public key from PEM to hex pt(compressed & uncompressed)')
    print('uncompressed key %s', Nakasendo.pubKeyPEMasHex(newKey.pubKey))
    print('compressed key %s', Nakasendo.pubKeyPEMasHex(newKey.pubKey, True))

    # Test1 randomPolynomial( degree, modulo )
    # Test2 randomPolynomial( degree, modulo, fixed a_0 )
    # Test3 randomPolynomial( degree, modulo, min, max )
    # Test4 evalute for x=2
    # Test5 create polynomial from list
Beispiel #2
0
    if (len(sys.argv) == 6):
        dersigStr = sys.argv[5]

    print('[%s, %s] \n pubkey %s \nmessage = %s' %
          (sigRStr, sigSStr, pubKeyStr, message))
    # 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')