chiark / gitweb /
catacomb/__init__.py: Calculate `X25519_BASE' and `X448_BASE'.
[catacomb-python] / catacomb / __init__.py
index 785838e67eb94830a2358670bcd86049ac0e889c..860cfb5e07cd3d119a45771fed15068b360fd572 100644 (file)
@@ -735,19 +735,15 @@ _augment(KCDSAPriv, _tmp)
 ###--------------------------------------------------------------------------
 ### Bernstein's elliptic curve crypto and related schemes.
 
-X25519_BASE = \
-  bytes('0900000000000000000000000000000000000000000000000000000000000000')
-
-X448_BASE = \
-  bytes('05000000000000000000000000000000000000000000000000000000'
-        '00000000000000000000000000000000000000000000000000000000')
+X25519_BASE = MP(9).storel(32)
+X448_BASE = MP(5).storel(56)
 
 Z128 = bytes('00000000000000000000000000000000')
 
 class _BoxyPub (object):
-  def __init__(me, pub, *kw, **kwargs):
+  def __init__(me, pub, *args, **kw):
     if len(pub) != me._PUBSZ: raise ValueError, 'bad public key'
-    super(_BoxyPub, me).__init__(*kw, **kwargs)
+    super(_BoxyPub, me).__init__(*args, **kw)
     me.pub = pub
   def __repr__(me): return '%s(pub = %r)' % (_clsname(me), me.pub)
   def _repr_pretty_(me, pp, cyclep):
@@ -759,10 +755,10 @@ class _BoxyPub (object):
     pp.end_group(ind, ')')
 
 class _BoxyPriv (_BoxyPub):
-  def __init__(me, priv, pub = None, *kw, **kwargs):
+  def __init__(me, priv, pub = None, *args, **kw):
     if len(priv) != me._KEYSZ: raise ValueError, 'bad private key'
     if pub is None: pub = me._op(priv, me._BASE)
-    super(_BoxyPriv, me).__init__(pub = pub, *kw, **kwargs)
+    super(_BoxyPriv, me).__init__(pub = pub, *args, **kw)
     me.priv = priv
   def agree(me, you): return me._op(me.priv, you.pub)
   def boxkey(me, recip):
@@ -770,7 +766,7 @@ class _BoxyPriv (_BoxyPub):
   def box(me, recip, n, m):
     return secret_box(me.boxkey(recip), n, m)
   def unbox(me, recip, n, c):
-    return secret_unbox(me.boxkey(recip, n, c))
+    return secret_unbox(me.boxkey(recip), n, c)
   def __repr__(me): return '%s(priv = %s, pub = %r)' % \
       (_clsname(me), _repr_secret(me.priv), me.pub)
   def _repr_pretty_(me, pp, cyclep):