urcrypt_ed_puck

This commit is contained in:
Paul Driver 2020-07-31 16:31:56 -07:00
parent 2369b4eae2
commit bd17aa70ca
9 changed files with 46 additions and 33 deletions

View File

@ -6,8 +6,8 @@
/* functions
*/
u3_noun
u3qc_add_double_scalarmult(u3_atom a,
static u3_atom
_cqee_add_double_scalarmult(u3_atom a,
u3_atom b,
u3_atom c,
u3_atom d)
@ -53,6 +53,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3qc_add_double_scalarmult(a, b, c, d);
return _cqee_add_double_scalarmult(a, b, c, d);
}
}

View File

@ -6,8 +6,8 @@
/* functions
*/
u3_noun
u3qc_add_scalarmult_scalarmult_base(u3_atom a,
static u3_atom
_cqee_add_scalarmult_scalarmult_base(u3_atom a,
u3_atom b,
u3_atom c)
{
@ -49,6 +49,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3qc_add_scalarmult_scalarmult_base(a, b, c);
return _cqee_add_scalarmult_scalarmult_base(a, b, c);
}
}

View File

@ -7,8 +7,8 @@
/* functions
*/
u3_noun
u3qc_point_add(u3_atom a,
static u3_atom
_cqee_point_add(u3_atom a,
u3_atom b)
{
c3_w ate_w, bet_w;
@ -43,6 +43,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3qc_point_add(a, b);
return _cqee_point_add(a, b);
}
}

View File

@ -2,32 +2,37 @@
**
*/
#include "all.h"
#include <ed25519.h>
#include <urcrypt.h>
/* functions
*/
static u3_atom
_cqee_puck(u3_atom sed)
{
c3_y sed_y[32], pub_y[32];
c3_w met_w;
if ( (met_w = u3r_met(3, sed)) > 32 ) {
// hoon explicitly crashes on mis-size
return u3m_bail(c3__exit);
}
memset(sed_y, 0, 32);
u3r_bytes(0, met_w, sed_y, sed);
urcrypt_ed_puck(sed_y, pub_y);
return u3i_bytes(32, pub_y);
}
u3_noun
u3wee_puck(u3_noun cor)
{
c3_y pub_y[32];
c3_y sec_y[64];
c3_y sed_y[32];
c3_w met_w;
u3_noun a = u3r_at(u3x_sam, cor);
if ( (u3_none == a) || (c3n == u3ud(a)) ) {
return u3m_bail(c3__exit);
}
met_w = u3r_met(3, a);
if ( met_w > 32 ) {
return u3m_bail(c3__exit);
else {
return _cqee_puck(a);
}
memset(sed_y, 0, 32);
u3r_bytes(0, met_w, sed_y, a);
ed25519_create_keypair(pub_y, sec_y, sed_y);
return u3i_bytes(32, pub_y);
}

View File

@ -6,8 +6,8 @@
/* functions
*/
u3_noun
u3qc_scalarmult(u3_atom a,
static u3_atom
_cqee_scalarmult(u3_atom a,
u3_atom b)
{
c3_w ate_w, bet_w;
@ -47,6 +47,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3qc_scalarmult(a, b);
return _cqee_scalarmult(a, b);
}
}

View File

@ -6,8 +6,8 @@
/* functions
*/
u3_noun
u3qc_scalarmult_base(u3_atom a)
static u3_atom
_cqee_scalarmult_base(u3_atom a)
{
c3_w met_w = u3r_met(3, a);
@ -34,6 +34,6 @@
return u3m_bail(c3__exit);
}
else {
return u3qc_scalarmult_base(a);
return _cqee_scalarmult_base(a);
}
}

View File

@ -6,7 +6,7 @@
/* functions
*/
static u3_noun
static u3_atom
_cqee_sign(u3_noun a,
u3_noun b)
{

View File

@ -119,6 +119,13 @@ urcrypt_ed_add_double_scalarmult(uint8_t a[32],
return 0;
}
void
urcrypt_ed_puck(uint8_t seed[32], uint8_t out[32])
{
uint8_t secret[64];
ed25519_create_keypair(out, secret, seed);
}
void
urcrypt_ed_sign(uint8_t *message,
size_t length,

View File

@ -18,9 +18,10 @@ int urcrypt_ed_add_double_scalarmult(uint8_t a[32],
uint8_t b[32],
uint8_t b_point[32],
uint8_t out[32]);
void urcrypt_ed_puck(uint8_t seed[32], uint8_t out[32]);
void urcrypt_ed_sign(uint8_t *message,
size_t length,
uint8_t seed[32],
uint8_t signature[64]);
uint8_t out[64]);
#endif