mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-03-21 22:33:10 +00:00
chore: use array of arrays with named obj structure for identity credential
This commit is contained in:
parent
861a776d05
commit
f39d215cca
@ -29,13 +29,13 @@ export class IdentityCredential {
|
||||
);
|
||||
}
|
||||
|
||||
public toJSON(): [number[], number[], number[], number[], string] {
|
||||
return [
|
||||
Array.from(this.IDTrapdoor),
|
||||
Array.from(this.IDNullifier),
|
||||
Array.from(this.IDSecretHash),
|
||||
Array.from(this.IDCommitment),
|
||||
this.IDCommitmentBigInt.toString()
|
||||
];
|
||||
public toJSON(): Record<string, number[] | string> {
|
||||
return {
|
||||
idTrapdoor: Array.from(this.IDTrapdoor),
|
||||
idNullifier: Array.from(this.IDNullifier),
|
||||
idSecretHash: Array.from(this.IDSecretHash),
|
||||
idCommitment: Array.from(this.IDCommitment),
|
||||
idCommitmentBigInt: this.IDCommitmentBigInt.toString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,11 +251,11 @@ export class Keystore {
|
||||
const str = bytesToUtf8(bytes);
|
||||
const obj = JSON.parse(str);
|
||||
|
||||
// Get identity arrays
|
||||
const [idTrapdoor, idNullifier, idSecretHash, idCommitment] = _.get(
|
||||
// Get identity fields from named object
|
||||
const { idTrapdoor, idNullifier, idSecretHash, idCommitment } = _.get(
|
||||
obj,
|
||||
"identityCredential",
|
||||
[]
|
||||
{}
|
||||
);
|
||||
|
||||
const idTrapdoorArray = new Uint8Array(idTrapdoor || []);
|
||||
@ -299,12 +299,12 @@ export class Keystore {
|
||||
return utf8ToBytes(
|
||||
JSON.stringify({
|
||||
treeIndex: options.membership.treeIndex,
|
||||
identityCredential: [
|
||||
Array.from(options.identity.IDTrapdoor),
|
||||
Array.from(options.identity.IDNullifier),
|
||||
Array.from(options.identity.IDSecretHash),
|
||||
Array.from(options.identity.IDCommitment)
|
||||
],
|
||||
identityCredential: {
|
||||
idTrapdoor: Array.from(options.identity.IDTrapdoor),
|
||||
idNullifier: Array.from(options.identity.IDNullifier),
|
||||
idSecretHash: Array.from(options.identity.IDSecretHash),
|
||||
idCommitment: Array.from(options.identity.IDCommitment)
|
||||
},
|
||||
membershipContract: {
|
||||
chainId: options.membership.chainId,
|
||||
address: options.membership.address
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user