Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add SignedUserTransaction.ed25519 and SignedUserTransaction.multi_ed2…
…5519
  • Loading branch information
wk3368 committed Oct 27, 2021
1 parent 952ce1f commit 152aa46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/lib/runtime/starcoin_types/index.ts
Expand Up @@ -527,8 +527,7 @@ export class MultiEd25519Signature {
if (num_of_sigs === 0 || num_of_sigs > MAX_NUM_OF_KEYS) {
throw new Error(CryptoMaterialError.ValidationError)
}
const sorted_signatures = origin_signatures
sorted_signatures.sort((a, b) => {
const sorted_signatures = origin_signatures.sort((a, b) => {
return a[1] > b[1] ? 1 : -1
})
const sigs = []
Expand Down Expand Up @@ -831,6 +830,16 @@ export class SignedUserTransaction {
return new SignedUserTransaction(raw_txn, authenticator);
}

static ed25519(raw_txn: RawUserTransaction, public_key: Ed25519PublicKey, signature: Ed25519Signature): SignedUserTransaction {
const authenticator = new TransactionAuthenticatorVariantEd25519(public_key, signature);
return new SignedUserTransaction(raw_txn, authenticator);
}

static multi_ed25519(raw_txn: RawUserTransaction, public_key: MultiEd25519PublicKey, signature: MultiEd25519Signature): SignedUserTransaction {
const authenticator = new TransactionAuthenticatorVariantMultiEd25519(public_key, signature);
return new SignedUserTransaction(raw_txn, authenticator);
}

}
export class StructTag {

Expand Down
1 change: 0 additions & 1 deletion src/utils/multi-sign.ts
Expand Up @@ -76,7 +76,6 @@ export async function createMultiEd25519KeyShard(originPublicKeys: Array<string>
return shard;
}


export async function signMultiEd25519KeyShard(multiEd25519KeyShard: MultiEd25519KeyShard, data?: any): Promise<MultiEd25519SignatureShard> {
const signatures = await Promise.all(
Object.keys(multiEd25519KeyShard.private_keys).map((k) => {
Expand Down

0 comments on commit 152aa46

Please sign in to comment.