Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update randomPasscode to return 21 characters #243

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/keri/app/coring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export function randomPasscode(): string {
const raw = libsodium.randombytes_buf(16);
const salter = new Salter({ raw: raw });

return salter.qb64.substring(2);
// https://github.com/WebOfTrust/signify-ts/issues/242
return salter.qb64.substring(2, 23);
}

export function randomNonce(): string {
Expand Down
13 changes: 12 additions & 1 deletion test/app/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import libsodium from 'libsodium-wrappers-sumo';
import { openManager } from '../../src/keri/core/manager';
import { Signer } from '../../src/keri/core/signer';
import { MtrDex } from '../../src/keri/core/matter';
import { Tier } from '../../src';
import { Tier, randomPasscode } from '../../src';

describe('Controller', () => {
it('manage account AID signing and agent verification', async () => {
Expand Down Expand Up @@ -44,4 +44,15 @@ describe('Controller', () => {
'EIIY2SgE_bqKLl2MlnREUawJ79jTuucvWwh-S6zsSUFo'
);
});

it('should generate unique controller AIDs per passcode', async () => {
await libsodium.ready;
const passcode1 = randomPasscode();
const passcode2 = randomPasscode();

const controller1 = new Controller(passcode1, Tier.low);
const controller2 = new Controller(passcode2, Tier.low);

assert.notEqual(controller1.pre, controller2.pre);
});
});
2 changes: 1 addition & 1 deletion test/app/coring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('Coring', () => {
it('Random passcode', async () => {
await libsodium.ready;
const passcode = randomPasscode();
assert.equal(passcode.length, 22);
assert.equal(passcode.length, 21);
});

it('Random nonce', async () => {
Expand Down
Loading