Unify keypair and seed_keypair
This commit is contained in:
parent
27f2f6eb45
commit
feed976315
@ -45,7 +45,7 @@ int vectors_xmss(uint32_t oid, int mt) {
|
|||||||
seed[i] = i;
|
seed[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmssmt_core_keypair2(¶ms, pk, sk, seed);
|
xmssmt_core_seed_keypair(¶ms, pk, sk, seed);
|
||||||
|
|
||||||
ull_to_bytes(sk, params.index_bytes, 1 << (params.full_height - 1));
|
ull_to_bytes(sk, params.index_bytes, 1 << (params.full_height - 1));
|
||||||
|
|
||||||
|
25
xmss_core.c
25
xmss_core.c
@ -131,7 +131,7 @@ int xmss_core_sign(const xmss_params *params,
|
|||||||
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
|
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
|
||||||
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
||||||
*/
|
*/
|
||||||
int xmssmt_core_keypair2(const xmss_params *params,
|
int xmssmt_core_seed_keypair(const xmss_params *params,
|
||||||
unsigned char *pk, unsigned char *sk,
|
unsigned char *pk, unsigned char *sk,
|
||||||
unsigned char *seed)
|
unsigned char *seed)
|
||||||
{
|
{
|
||||||
@ -168,27 +168,10 @@ int xmssmt_core_keypair2(const xmss_params *params,
|
|||||||
int xmssmt_core_keypair(const xmss_params *params,
|
int xmssmt_core_keypair(const xmss_params *params,
|
||||||
unsigned char *pk, unsigned char *sk)
|
unsigned char *pk, unsigned char *sk)
|
||||||
{
|
{
|
||||||
/* We do not need the auth path in key generation, but it simplifies the
|
unsigned char seed[3 * params->n];
|
||||||
code to have just one treehash routine that computes both root and path
|
|
||||||
in one function. */
|
|
||||||
unsigned char auth_path[params->tree_height * params->n];
|
|
||||||
uint32_t top_tree_addr[8] = {0};
|
|
||||||
set_layer_addr(top_tree_addr, params->d - 1);
|
|
||||||
|
|
||||||
/* Initialize index to 0. */
|
randombytes(seed, 3 * params->n);
|
||||||
memset(sk, 0, params->index_bytes);
|
xmssmt_core_seed_keypair(params, pk, sk, seed);
|
||||||
sk += params->index_bytes;
|
|
||||||
|
|
||||||
/* Initialize SK_SEED and SK_PRF. */
|
|
||||||
randombytes(sk, 2 * params->n);
|
|
||||||
|
|
||||||
/* Initialize PUB_SEED. */
|
|
||||||
randombytes(sk + 3 * params->n, params->n);
|
|
||||||
memcpy(pk + params->n, sk + 3*params->n, params->n);
|
|
||||||
|
|
||||||
/* Compute root node of the top-most subtree. */
|
|
||||||
treehash(params, pk, auth_path, sk, pk + params->n, 0, top_tree_addr);
|
|
||||||
memcpy(sk + 2*params->n, pk, params->n);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ int xmssmt_core_keypair(const xmss_params *params,
|
|||||||
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
|
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
|
||||||
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
||||||
*/
|
*/
|
||||||
int xmssmt_core_keypair2(const xmss_params *params,
|
int xmssmt_core_seed_keypair(const xmss_params *params,
|
||||||
unsigned char *pk, unsigned char *sk,
|
unsigned char *pk, unsigned char *sk,
|
||||||
unsigned char *seed);
|
unsigned char *seed);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user