This commit is contained in:
Christien Rioux 2023-07-09 10:55:26 -04:00
parent ac58e1dea3
commit d74d60779b
2 changed files with 329 additions and 37 deletions

View File

@ -40,49 +40,58 @@ class LocalAccountManager {
final dhtctx = (await Veilid.instance.routingContext())
.withPrivacy()
.withSequencing(Sequencing.ensureOrdered);
final masterRec =
await dhtctx.createDHTRecord(const DHTSchema.dflt(oCnt: 1));
final identityRec =
await dhtctx.createDHTRecord(const DHTSchema.dflt(oCnt: 1));
final crypto = await Veilid.instance.bestCryptoSystem();
assert(masterRec.key.kind == crypto.kind());
assert(identityRec.key.kind == crypto.kind());
DHTRecordDescriptor? masterRec;
DHTRecordDescriptor? identityRec;
try {
masterRec = await dhtctx.createDHTRecord(const DHTSchema.dflt(oCnt: 1));
identityRec = await dhtctx.createDHTRecord(const DHTSchema.dflt(oCnt: 1));
final crypto = await Veilid.instance.bestCryptoSystem();
assert(masterRec.key.kind == crypto.kind());
assert(identityRec.key.kind == crypto.kind());
// IdentityMaster
final masterRecordKey = masterRec.key;
final masterPublicKey = masterRec.owner;
final masterSecret = masterRec.ownerSecret!;
final masterSigBuf = masterRecordKey.decode()
..addAll(masterPublicKey.decode());
// IdentityMaster
final masterRecordKey = masterRec.key;
final masterPublicKey = masterRec.owner;
final masterSecret = masterRec.ownerSecret!;
final masterSigBuf = masterRecordKey.decode()
..addAll(masterPublicKey.decode());
final identityRecordKey = identityRec.key;
final identityPublicKey = identityRec.owner;
final identitySecret = identityRec.ownerSecret!;
final identitySigBuf = identityRecordKey.decode()
..addAll(identityPublicKey.decode());
final identityRecordKey = identityRec.key;
final identityPublicKey = identityRec.owner;
final identitySecret = identityRec.ownerSecret!;
final identitySigBuf = identityRecordKey.decode()
..addAll(identityPublicKey.decode());
final identitySignature =
await crypto.sign(masterPublicKey, masterSecret, identitySigBuf);
final masterSignature =
await crypto.sign(identityPublicKey, identitySecret, masterSigBuf);
final identitySignature =
await crypto.sign(masterPublicKey, masterSecret, identitySigBuf);
final masterSignature =
await crypto.sign(identityPublicKey, identitySecret, masterSigBuf);
final identityMaster = IdentityMaster(
identityRecordKey: identityRecordKey,
identityPublicKey: identityPublicKey,
masterRecordKey: masterRecordKey,
masterPublicKey: masterPublicKey,
identitySignature: identitySignature,
masterSignature: masterSignature);
final identityMaster = IdentityMaster(
identityRecordKey: identityRecordKey,
identityPublicKey: identityPublicKey,
masterRecordKey: masterRecordKey,
masterPublicKey: masterPublicKey,
identitySignature: identitySignature,
masterSignature: masterSignature);
// Write identity master to master dht key
final identityMasterBytes =
Uint8List.fromList(utf8.encode(jsonEncode(identityMaster)));
await dhtctx.setDHTValue(masterRecordKey, 0, identityMasterBytes);
// Write identity master to master dht key
final identityMasterBytes =
Uint8List.fromList(utf8.encode(jsonEncode(identityMaster)));
await dhtctx.setDHTValue(masterRecordKey, 0, identityMasterBytes);
return IdentityMasterWithSecrets(
identityMaster: identityMaster,
masterSecret: masterSecret,
identitySecret: identitySecret);
return IdentityMasterWithSecrets(
identityMaster: identityMaster,
masterSecret: masterSecret,
identitySecret: identitySecret);
} catch (e) {
if (masterRec != null) {
await dhtctx.deleteDHTRecord(masterRec.key);
}
if (identityRec != null) {
await dhtctx.deleteDHTRecord(identityRec.key);
}
}
}
/// Creates a new account associated with master identity

283
lib/tools/phono_byte.dart Normal file
View File

@ -0,0 +1,283 @@
// Implementation of https://github.com/meeb/phonobyte
import 'dart:typed_data';
const phonoWords = [
'jab',
'tip',
'led',
'rut',
'dak',
'jig',
'rud',
'pub',
'not',
'kid',
'bid',
'gup',
'lep',
'juk',
'jib',
'sid',
'fon',
'dug',
'lap',
'sog',
'bug',
'ret',
'net',
'fip',
'gad',
'peg',
'gap',
'fet',
'rog',
'lob',
'lin',
'pip',
'fud',
'lag',
'gut',
'reb',
'din',
'sun',
'jun',
'dig',
'rag',
'neg',
'bin',
'ben',
'gob',
'run',
'fab',
'lit',
'ked',
'rug',
'lod',
'rib',
'rip',
'sod',
'ped',
'dip',
'leg',
'sib',
'sad',
'sat',
'pak',
'jet',
'bun',
'gon',
'geg',
'bit',
'gud',
'rig',
'dek',
'pot',
'pug',
'ken',
'gub',
'rid',
'pen',
'nep',
'gib',
'jot',
'pup',
'tid',
'sin',
'kin',
'job',
'ted',
'fun',
'fop',
'dan',
'nip',
'but',
'tun',
'put',
'jog',
'jit',
'lad',
'pig',
'got',
'tot',
'gak',
'sot',
'rin',
'lid',
'don',
'den',
'pod',
'rit',
'gat',
'ket',
'sab',
'rat',
'bub',
'dod',
'dep',
'dup',
'tod',
'lat',
'nub',
'lab',
'pan',
'rap',
'tib',
'tan',
'bed',
'seg',
'lib',
'kop',
'fog',
'tig',
'sob',
'pet',
'lop',
'bet',
'bog',
'nog',
'gun',
'lud',
'sit',
'dib',
'dap',
'ban',
'kob',
'nan',
'pat',
'pib',
'lip',
'fan',
'big',
'get',
'bob',
'rad',
'ran',
'san',
'rot',
'bad',
'nop',
'nid',
'jut',
'nod',
'bap',
'fad',
'ten',
'gid',
'dop',
'dit',
'fid',
'tap',
'bib',
'dog',
'lek',
'tog',
'deg',
'fob',
'deb',
'beg',
'kan',
'sug',
'tup',
'ton',
'gag',
'dot',
'lot',
'keg',
'pap',
'ren',
'fit',
'kip',
'tub',
'tin',
'pad',
'bip',
'pun',
'tug',
'nap',
'sag',
'dob',
'gig',
'sup',
'tag',
'fub',
'reg',
'top',
'jag',
'nib',
'sig',
'kit',
'dag',
'set',
'dud',
'bab',
'sud',
'sub',
'dub',
'nit',
'fed',
'nat',
'tad',
'dab',
'fen',
'nun',
'lug',
'kut',
'rep',
'fib',
'nab',
'nag',
'bok',
'gab',
'bot',
'bud',
'dad',
'sap',
'tat',
'did',
'gog',
'dat',
'rub',
'pud',
'bop',
'lig',
'dut',
'pep',
'fug',
'bod',
'sed',
'sen',
'teg',
'pit',
'fin',
'dun',
'rob',
'let',
'neb',
'tut',
'sop',
'gan',
'fig',
'tab'
];
String prettyPhonoString(String s) {
}
String canonicalPhonoString(String s) {
}
Uint8List decodePhono(String s) {
try {
}
//FormatException
}
String encodePhono(Uint8List b) {
}