예제 #1
0
def create_ed_keys(urandom=os.urandom):
    sk, pk = make_ed25519_keypair(urandom)
    pk_human = Base58.encode_version(
        Base58.VER_NODE_PUBLIC, ED25519_BYTE + pk)
    sk_human = Base58.encode_version(
        Base58.VER_NODE_PRIVATE, sk)
    return pk_human, sk_human
예제 #2
0
def create_ed_keys(urandom=os.urandom):
    private_key, public_key = make_ed25519_keypair(urandom)
    public_key_human = Base58.encode_version(Base58.VER_NODE_PUBLIC,
                                             ED25519_BYTE + public_key)
    private_key_human = Base58.encode_version(Base58.VER_NODE_PRIVATE,
                                              private_key)
    return public_key_human, private_key_human
예제 #3
0
파일: Sign.py 프로젝트: yunsite/rippled
def create_ed_public_key(private_key_human):
    v, private_key = Base58.decode_version(private_key_human)
    check_master_secret(v, private_key)

    public_key = ed25519.publickey(private_key)
    public_key_human = Base58.encode_version(Base58.VER_NODE_PUBLIC, ED25519_BYTE + public_key)
    return public_key_human
예제 #4
0
파일: Sign.py 프로젝트: yunsite/rippled
def check_validator_public(v, validator_public_key):
    Base58.check_version(v, Base58.VER_NODE_PUBLIC)
    if len(validator_public_key) != 33:
        raise ValueError("Validator key should be length 33, is %s" % len(validator_public_key))
    b = ord(validator_public_key[0])
    if b not in (2, 3):
        raise ValueError("First validator key byte must be 2 or 3, is %d" % b)
예제 #5
0
def create_ed_keys(urandom=os.urandom):
    private_key, public_key = make_ed25519_keypair(urandom)
    public_key_human = Base58.encode_version(
        Base58.VER_NODE_PUBLIC, ED25519_BYTE + public_key)
    private_key_human = Base58.encode_version(
        Base58.VER_NODE_PRIVATE, private_key)
    return public_key_human, private_key_human
예제 #6
0
def create_ed_public_key(sk_human):
    v, sk = Base58.decode_version(sk_human)
    check_secret_key(v, sk)

    pk = ed25519.publickey(sk)
    pk_human = Base58.encode_version(Base58.VER_NODE_PUBLIC, ED25519_BYTE + pk)
    return pk_human
예제 #7
0
    def get_test_keypair(self):
        public = (Base58.VER_NODE_PUBLIC, '\x02' + (32 * 'v'))
        private = (Base58.VER_NODE_PRIVATE, 32 * 'k')

        Sign.check_validator_public(*public)
        Sign.check_master_secret(*private)

        return (Base58.encode_version(*public), Base58.encode_version(*private))
예제 #8
0
def check_validator_public(v, validator_public_key):
    Base58.check_version(v, Base58.VER_NODE_PUBLIC)
    if len(validator_public_key) != 33:
        raise ValueError('Validator key should be length 33, is %s' %
                         len(validator_public_key))
    b = ord(validator_public_key[0])
    if b not in (2, 3):
        raise ValueError('First validator key byte must be 2 or 3, is %d' % b)
예제 #9
0
파일: test_Sign.py 프로젝트: E-LLP/rippled
    def get_test_keypair(self):
        public = (Base58.VER_NODE_PUBLIC, '\x02' + (32 * 'v'))
        private = (Base58.VER_NODE_PRIVATE, 32 * 'k')

        Sign.check_validator_public(*public)
        Sign.check_master_secret(*private)

        return (Base58.encode_version(*public), Base58.encode_version(*private))
예제 #10
0
파일: Sign.py 프로젝트: bitcoin2-0/bitcoind
def create_ed_public_key(private_key_human):
    v, private_key = Base58.decode_version(private_key_human)
    check_master_secret(v, private_key)

    public_key = ed25519.publickey(private_key)
    public_key_human = Base58.encode_version(Base58.VER_NODE_PUBLIC,
                                             ED25519_BYTE + public_key)
    return public_key_human
예제 #11
0
def check_validation_public_key(v, pk):
    Base58.check_version(v, Base58.VER_NODE_PUBLIC)
    if len(pk) != 33:
        raise ValueError('Validation public key should be length 33, is %s' %
                         len(pk))
    b = ord(pk[0])
    if b not in (2, 3):
        raise ValueError('First validation public key byte must be 2 or 3, is %d' % b)
예제 #12
0
def create_ed_public_key(sk_human):
    v, sk = Base58.decode_version(sk_human)
    check_secret_key(v, sk)

    pk = ed25519.publickey(sk)
    pk_human = Base58.encode_version(
        Base58.VER_NODE_PUBLIC, ED25519_BYTE + pk)
    return pk_human
예제 #13
0
파일: Sign.py 프로젝트: yunsite/rippled
def verify_signature(seq, validator_public_key_human, public_key_human, signature):
    v, validator_public_key = Base58.decode_version(validator_public_key_human)
    check_validator_public(v, validator_public_key)

    v, public_key = Base58.decode_version(public_key_human)

    m = make_manifest(public_key, validator_public_key, seq)
    public_key = public_key[1:]  # Remove ED25519_BYTE
    sig = signature.decode("hex")
    ed25519.checkvalid(sig, "MAN\0" + m, public_key)
예제 #14
0
파일: Sign.py 프로젝트: sznu2008/rippled
def verify_signature(seq, validator_public_key_human, public_key_human,
                     signature):
    v, validator_public_key = Base58.decode_version(validator_public_key_human)
    check_validator_public(v, validator_public_key)

    v, public_key = Base58.decode_version(public_key_human)

    m = make_manifest(public_key, validator_public_key, seq)
    public_key = public_key[1:]  # Remove ED25519_BYTE
    sig = signature.decode('hex')
    ed25519.checkvalid(sig, 'MAN\0' + m, public_key)
예제 #15
0
def get_signature(seq, validator_public_key_human, private_key_human):
    v, validator_public_key = Base58.decode_version(validator_public_key_human)
    check_validator_public(v, validator_public_key)

    v, private_key = Base58.decode_version(private_key_human)
    check_master_secret(v, private_key)

    pk = ed25519.publickey(private_key)
    apk = ED25519_BYTE + pk
    m = make_manifest(apk, validator_public_key, seq)
    m1 = sign_manifest(m, private_key, pk)
    return base64.b64encode(m1)
예제 #16
0
파일: Sign.py 프로젝트: yunsite/rippled
def get_signature(seq, validator_public_key_human, private_key_human):
    v, validator_public_key = Base58.decode_version(validator_public_key_human)
    check_validator_public(v, validator_public_key)

    v, private_key = Base58.decode_version(private_key_human)
    check_master_secret(v, private_key)

    pk = ed25519.publickey(private_key)
    apk = ED25519_BYTE + pk
    m = make_manifest(apk, validator_public_key, seq)
    m1 = sign_manifest(m, private_key, pk)
    return base64.b64encode(m1)
예제 #17
0
def get_signature(seq, validation_pk_human, validation_sk_human, master_sk_human):
    v, validation_pk = Base58.decode_version(validation_pk_human)
    check_validation_public_key(v, validation_pk)

    v, validation_sk_str = Base58.decode_version(validation_sk_human)
    check_secret_key(v, validation_sk_str)
    validation_sk = ecdsa.SigningKey.from_string(validation_sk_str, curve=ecdsa.SECP256k1)

    v, master_sk = Base58.decode_version(master_sk_human)
    check_secret_key(v, master_sk)

    pk = ed25519.publickey(master_sk)
    apk = ED25519_BYTE + pk
    m = make_manifest(apk, validation_pk, seq)
    m1 = sign_manifest(m, validation_sk, master_sk, pk)
    return base64.b64encode(m1)
예제 #18
0
def get_signature(seq, validation_pk_human, validation_sk_human,
                  master_sk_human):
    v, validation_pk = Base58.decode_version(validation_pk_human)
    check_validation_public_key(v, validation_pk)

    v, validation_sk_str = Base58.decode_version(validation_sk_human)
    check_secret_key(v, validation_sk_str)
    validation_sk = ecdsa.SigningKey.from_string(validation_sk_str,
                                                 curve=ecdsa.SECP256k1)

    v, master_sk = Base58.decode_version(master_sk_human)
    check_secret_key(v, master_sk)

    pk = ed25519.publickey(master_sk)
    apk = ED25519_BYTE + pk
    m = make_manifest(apk, validation_pk, seq)
    m1 = sign_manifest(m, validation_sk, master_sk, pk)
    return base64.b64encode(m1)
예제 #19
0
def perform_sign(seq,
                 validation_pk_human,
                 validation_sk_human,
                 master_sk_human,
                 print=print):
    manifest = get_signature(int(seq), validation_pk_human,
                             validation_sk_human, master_sk_human)

    print('[validator_token]')
    print(
        wrap(
            base64.b64encode(
                json.dumps(
                    {
                        "validation_secret_key":
                        binascii.b2a_hex(
                            Base58.decode_version(validation_sk_human)[1]),
                        "manifest":
                        manifest
                    },
                    separators=(',', ':')))))
예제 #20
0
 def test_encode(self):
     self.assertEquals(
         Base58.encode_version(Base58.VER_ACCOUNT_PUBLIC, BINARY),
         'sB49XwJgmdEZDo8LmYwki7FYkiaN7')
예제 #21
0
 def test_check(self):
     public = Base58.encode_version(Base58.VER_NODE_PRIVATE, 32 * 'k')
     Sign.perform_check(public, self.print)
     self.assertEquals(self.results,
                       [[['version        = VER_NODE_PRIVATE'], {}],
                        [['decoded length = 32'], {}]])
예제 #22
0
 def test_decode(self):
     ver, b = Base58.decode_version('sB49XwJgmdEZDo8LmYwki7FYkiaN7')
     self.assertEquals(ver, Base58.VER_ACCOUNT_PUBLIC)
     self.assertEquals(b, BINARY)
예제 #23
0
파일: Sign.py 프로젝트: yunsite/rippled
def check_master_secret(v, private_key):
    Base58.check_version(v, Base58.VER_NODE_PRIVATE)
    if len(private_key) != 32:
        raise ValueError("Length of master secret should be 32, is %s" % len(private_key))
예제 #24
0
def create_ed_keys(urandom=os.urandom):
    sk, pk = make_ed25519_keypair(urandom)
    pk_human = Base58.encode_version(Base58.VER_NODE_PUBLIC, ED25519_BYTE + pk)
    sk_human = Base58.encode_version(Base58.VER_NODE_PRIVATE, sk)
    return pk_human, sk_human
예제 #25
0
 def run_test(self, before, after):
     self.assertEquals(Base58.decode(before), after)
     self.assertEquals(Base58.encode(after), before)
예제 #26
0
def check_secret_key(v, sk):
    Base58.check_version(v, Base58.VER_NODE_PRIVATE)
    if len(sk) != 32:
        raise ValueError('Length of master secret should be 32, is %s' %
                         len(sk))
예제 #27
0
파일: test_Sign.py 프로젝트: E-LLP/rippled
 def test_check(self):
     public = Base58.encode_version(Base58.VER_NODE_PRIVATE, 32 * 'k')
     Sign.perform_check(public, self.print)
     self.assertEquals(self.results,
                       [[['version        = VER_NODE_PRIVATE'], {}],
                        [['decoded length = 32'], {}]])
예제 #28
0
 def test_check(self):
     self.assertEquals(Base58.checksum(BINARY), '\xaa\xaar\x9d')
예제 #29
0
 def test_encode(self):
     self.assertEquals(
         Base58.encode_version(Base58.VER_ACCOUNT_PUBLIC, BINARY),
         'sB49XwJgmdEZDo8LmYwki7FYkiaN7')
예제 #30
0
파일: Sign.py 프로젝트: yunsite/rippled
def perform_check(s, print=print):
    version, b = Base58.decode_version(s)
    print("version        = " + Base58.version_name(version))
    print("decoded length = " + str(len(b)))
    assert Base58.encode_version(version, b) == s
예제 #31
0
def check_master_secret(v, private_key):
    Base58.check_version(v, Base58.VER_NODE_PRIVATE)
    if len(private_key) != 32:
        raise ValueError('Length of master secret should be 32, is %s' %
                         len(private_key))
예제 #32
0
 def run_test(self, before, after):
     self.assertEquals(Base58.decode(before), after)
     self.assertEquals(Base58.encode(after), before)
예제 #33
0
def perform_check(s, print=print):
    version, b = Base58.decode_version(s)
    print('version        = ' + Base58.version_name(version))
    print('decoded length = ' + str(len(b)))
    assert Base58.encode_version(version, b) == s
예제 #34
0
 def test_decode(self):
     ver, b = Base58.decode_version('sB49XwJgmdEZDo8LmYwki7FYkiaN7')
     self.assertEquals(ver, Base58.VER_ACCOUNT_PUBLIC)
     self.assertEquals(b, BINARY)
예제 #35
0
def check_secret_key(v, sk):
    Base58.check_version(v, Base58.VER_NODE_PRIVATE)
    if len(sk) != 32:
        raise ValueError('Length of master secret should be 32, is %s' %
                         len(sk))
예제 #36
0
 def test_check(self):
     self.assertEquals(Base58.checksum(BINARY), '\xaa\xaar\x9d')