PY25519,

py25519的Python项目详细描述


PY25519

Mehdi Sotoodeh的Python wrapper around curve25519。下面的文件 PY25519/C来自Mehdi Sotoodeh,未经修改复制自 https://github.com/msotoodeh/curve25519

许可证

py25519/c下的文件是在mit许可下授权的(参见 py25519/c下的license.txt文件)。

此软件包中的所有剩余文件都是根据gnu general授权的 公共许可证版本3或(由您选择)任何更高版本。

有关GNU通用公共文件的详细信息,请参阅文件license-gplv3.txt 许可证版本3。

课程文档

class Key25519(__builtin__.object)
      __init__(self, secretkey=None, verifyingkey=None, pubkey=None)
        '''
          secretkey-->bytes[32]
            verifyingkey-->bytes[32]
          pubkey-->bytes[32]

          A PublicKey version of the object will have ONLY verifyingkey
          and pubkey and signingkey will be None
          A PrivateKey version of the object will have secretkey set
          and verifyingkey and pubkey are ignored and derived from secretkey

          Storing and reusing the secretkey is a way to recreate your key pair
        '''

      get_ecdh_key(self, other)
        '''
          other-->Key25519 instance
        '''

      public_key(self)
        '''
          Returns a PublicKey version of this object
        '''

      selftest(self)
        '''
          Returns-->boolean
        '''

      serialize(self)

      sign = wrapped(*args, **kwargs)

      verify = wrapped(*args, **kwargs)

      # ---------------------------------------------------------------------
      # Properties (data descriptors)
      # ---------------------------------------------------------------------

      pubkey

      secretkey

      signingkey

      verifyingkey

简单测试

参见py25519.test.py

from py25519 import Key25519


c = Key25519()
print('secretkey: ', c.secretkey)
print('signingkey: ', c.signingkey)
print('verifyingkey: ', c.verifyingkey)

msg = 'Hello world'
badmsg = msg + '1'
sig = c.sign(msg)
badsig = c.sign(badmsg)
print('good verify: ', c.verify(sig, msg))
print('badmsg verify: ', c.verify(sig, badmsg))
print('badsig verify: ', c.verify(badsig, msg))

d = Key25519(secretkey=c.secretkey)
print('----- d is a copy of c -----')
print('d.verify: ', d.verify(sig, msg))
print('c == d:', c == d)
print('public(c) == public(d):', c.public_key() == d.public_key())
print('c == public(d):', c == d.public_key())

print('----- e is a new different key -----')
e = Key25519()
print('e.verify: ', e.verify(sig, msg))
print('c == e:', c == e)
print('public(c) == public(e):', c.public_key() == e.public_key())

print('----- Test ECDH shared key -----')
ecdh1 = c.get_ecdh_key(e.public_key())
ecdh2 = e.get_ecdh_key(c.public_key())
print('ecdh equal: ', ecdh1 == ecdh2)
ecdh3 = e.get_ecdh_key(c.public_key())
print('ecdh equal again: ', ecdh1 == ecdh3)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
调整大小时清除java JFrame图像   java Inmemory数据库和编程语言内存管理/垃圾收集   如何在Java中循环参数   java嵌套回收视图未获得焦点   hadoop和spark现在支持IPv6吗?   java允许在类中使用动态值。名字?   java中的Zookeeper连接   java如何从特定格式的字符串中提取数字?   java我在编译时没有收到错误,但当我运行程序时,我收到错误   用于指定身份验证架构的java Swagger配置   java AWS:elastic beanstalk是否隐式使用s3(存储)?   java如何向另一个servlet发送http请求   java写和写的区别是什么?   java在PCAP上循环了两次,这在io上是不可能的。pkts?   java ExecutionException SocketTimeoutException,同时尝试使用CompletableFuture异步调用10个不同的rest服务   svn中的eclipse Java项目,将其与maven结合   java Android数学简单   hadoop中的java多路输出格式