Esempio n. 1
0
def sign(value, k):
    k = FQ(k)
    B = Point.from_hash(b'eddsa_base')
    m = bytes.fromhex(hex(int(toBinaryString(value), 2))[2:])
    R, S, A = eddsa_sign(m, k, B)
    assert eddsa_verify(A, R, S, m, B)
    return R, S
Esempio n. 2
0
    def test_signverify(self):
        B = Point.from_hash(b'eddsa_base')
        k = FQ.random(JUBJUB_L)
        A = B * k
        m = urandom(32)
        R, s = eddsa_sign(m, k, B, A)

        self.assertTrue(eddsa_verify(A, R, s, m, B))
Esempio n. 3
0
    def test_signverify(self):
        B = Point.from_hash(b'eddsa_base')
        #B = None
        k, A = eddsa_random_keypair()
        m = urandom(32)

        smsg = eddsa_sign(m, k, B)
        self.assertTrue(eddsa_verify(*smsg, B))

        smsg = pureeddsa_sign(m, k, B)
        self.assertTrue(pureeddsa_verify(*smsg, B))
Esempio n. 4
0
 def test_hash_eddsa(self):
     # Used to verify compatibility with test_jubjub_eddsa.cpp
     B = Point(
         FQ(21609035313031231356478892405209584931807557563713540183143349090940105307553
            ),
         FQ(845281570263603011277359323511710394920357596931617398831207691379369851278
            ))
     A = Point(
         FQ(5616630816018221659484394091994939318481030030481519242876140465113436048304
            ),
         FQ(8476221375891900895034976644661703008703725320613595264559419965669922411183
            ))
     R = Point(
         FQ(17883110238616315155327756854433987355427639458557188556819876765548551765197
            ),
         FQ(11833558192785987866925773659755699683735551950878443451361314529874236222818
            ))
     s = 9920504625278683304895036460477595239370241328717115039061027107077120437288
     m = b'abc'
     self.assertTrue(eddsa_verify(A, (R, s), m, B))
     self.assertFalse(pureeddsa_verify(A, (R, s), m, B))
Esempio n. 5
0
 def test_pure_eddsa(self):
     # Used to verify compatibility with test_jubjub_eddsa.cpp
     B = Point(
         FQ(16117159321177103813813294286550615556837550473658220567209763364611339839115
            ),
         FQ(11465736382824868633493204496205282307637286781164666440541087834417561817657
            ))
     A = Point(
         FQ(7232078318593313024960606529959628262327760580530543297615441605656275483008
            ),
         FQ(13445187542498117393920468884784587115570437154948817232436446927611108297778
            ))
     R = Point(
         FQ(16748186150368319377210820880944935248945916993910817768852007732596413990860
            ),
         FQ(4850962850934517657076914998696277193398065576910427229359881798401199408131
            ))
     s = 9530517511211249528464523051059372760063486304291273287859289432498093931519
     m = b'abcd'
     self.assertTrue(pureeddsa_verify(A, (R, s), m, B))
     self.assertFalse(eddsa_verify(A, (R, s), m, B))
Esempio n. 6
0
def verify(value, R, S, A):
    R = Point(FQ(R[0]), FQ(R[1]))
    A = Point(FQ(A[0]), FQ(A[1]))
    B = Point.from_hash(b'eddsa_base')
    m = bytes.fromhex(hex(int(toBinaryString(value), 2))[2:])
    return eddsa_verify(A, R, S, m, B)