Skip to content
Snippets Groups Projects
Commit b8440c14 authored by Millicent Billette's avatar Millicent Billette
Browse files

Merge branch 'main' into 'main'

crypto: test if it's pubkey

See merge request !1
parents 778dd00d 759fbe05
No related branches found
No related tags found
1 merge request!1crypto: test if it's pubkey
Pipeline #15708 passed with warnings
......@@ -12,6 +12,8 @@ const sha256 = sha();
const generateKeypair = nacl.sign.keyPair.fromSeed;
export const isPubkey = (value) => /^[A-HJ-NP-Za-km-z1-9]{42,45}$/.test(value)
export async function idSecPass2rawAll(idSec, pass) {
const rawSeed = await saltPass2seed(idSec, pass);
const keyPair = await seed2keyPair(rawSeed);
......
......@@ -30,6 +30,7 @@ test('array sign string', async t => t.is((await app.sign(unsignedDocument, secr
test('uint8array sign string', async t => t.is((await app.sign(unsignedDocument, secretKey, 'uint8array'))[0], 27));
test('sign throw for bad output format', async t => t.throwsAsync(() => app.sign(unsignedDocument, secretKey, 'whattt ?')));
test("is a pubkey", (t) => t.is(app.isPubkey(pubKey), true));
test('b58 should decode/encode well', t => t.is(app.b58.encode(app.b58.decode(pubKey)), pubKey));
test('b58 on pubKey with leading 1', t => t.is(app.b58.encode(app.b58.decode('12BjyvjoAf5qik7R8TKDJAHJugsX23YgJGi2LmBUv2nx')), '12BjyvjoAf5qik7R8TKDJAHJugsX23YgJGi2LmBUv2nx'));
test('b58 on pubKey without leading 1', t => t.is(app.b58.encode(app.b58.decode('2BjyvjoAf5qik7R8TKDJAHJugsX23YgJGi2LmBUv2nx')), '2BjyvjoAf5qik7R8TKDJAHJugsX23YgJGi2LmBUv2nx'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment