Ejemplo n.º 1
0
 def new_identity(self, name, type, sigkey, deckey):
     verkey = crypto.priv_to_pub(sigkey)
     enckey = crypto.priv_to_pub(deckey)
     ripe = crypto.to_ripe(verkey, enckey)
     self.names.set(ripe, name)
     address = Address(4, config.NETWORK_STREAM, ripe)
     self._db.execute('insert into identities (address, name, sigkey, deckey) values (?, ?, ?, ?)',
             (address.to_bytes(), type, sigkey, deckey))
     self._db.execute('insert into profiles (address, name, verkey, enckey) values (?, ?, ?, ?)',
             (address.to_bytes(), type, b'\x04'+verkey, b'\x04'+enckey))
     identity = Identity2(self._db, address)
     for func in self.on_add_identity:
         func(identity)
     return identity
Ejemplo n.º 2
0
 def new_deterministic(self, name, type, text):
     for i in range(0, 2**64, 2):
         s1 = serialize.Serializer()
         s1.str(text)
         s1.vint(i)
         sigkey = crypto.sha512(s1.data)[0:32]
         s2 = serialize.Serializer()
         s2.str(text)
         s2.vint(i + 1)
         deckey = crypto.sha512(s2.data)[0:32]
         verkey = crypto.priv_to_pub(sigkey)
         enckey = crypto.priv_to_pub(deckey)
         ripe = crypto.to_ripe(verkey, enckey)
         if ripe[0:1] == b'\x00':
             return self.new_identity(name, type, sigkey, deckey)
Ejemplo n.º 3
0
 def new_deterministic(self, name, type, text):
     for i in range(0, 2**64, 2):
         s1 = serialize.Serializer()
         s1.str(text)
         s1.vint(i)
         sigkey = crypto.sha512(s1.data)[0:32]
         s2 = serialize.Serializer()
         s2.str(text)
         s2.vint(i + 1)
         deckey = crypto.sha512(s2.data)[0:32]
         verkey = crypto.priv_to_pub(sigkey)
         enckey = crypto.priv_to_pub(deckey)
         ripe = crypto.to_ripe(verkey, enckey)
         if ripe[0:1] == b'\x00':
             return self.new_identity(name, type, sigkey, deckey)
Ejemplo n.º 4
0
 def new_identity(self, name, type, sigkey, deckey):
     verkey = crypto.priv_to_pub(sigkey)
     enckey = crypto.priv_to_pub(deckey)
     ripe = crypto.to_ripe(verkey, enckey)
     self.names.set(ripe, name)
     address = Address(4, config.NETWORK_STREAM, ripe)
     self._db.execute(
         'insert into identities (address, name, sigkey, deckey) values (?, ?, ?, ?)',
         (address.to_bytes(), type, sigkey, deckey))
     self._db.execute(
         'insert into profiles (address, name, verkey, enckey) values (?, ?, ?, ?)',
         (address.to_bytes(), type, b'\x04' + verkey, b'\x04' + enckey))
     identity = Identity2(self._db, address)
     for func in self.on_add_identity:
         func(identity)
     return identity