-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds multisig/aggregateSigningShares RPC (#4677)
* adds multisig/aggregateSignatureShares RPC takes a publicKeyPackage, an unsignedTransaction, a signingPackage for that transaction, and a list of signatureShares for that signingPackage uses UnsignedTransaction.signFrost to aggregate the signatureShares, sign the transaction, and produce a signed transaction returns a signed transaction serialized as hex * fixes typo in RpcClient s/Signature/Signing/ * fixes second typo
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
ironfish/src/rpc/routes/multisig/aggregateSigningShares.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { UnsignedTransaction } from '@ironfish/rust-nodejs' | ||
import * as yup from 'yup' | ||
import { ApiNamespace } from '../namespaces' | ||
import { routes } from '../router' | ||
|
||
export type AggregateSigningSharesRequest = { | ||
publicKeyPackage: string | ||
unsignedTransaction: string | ||
signingPackage: string | ||
signingShares: Array<{ | ||
identifier: string | ||
signingShare: string | ||
}> | ||
} | ||
|
||
export type AggregateSigningSharesResponse = { | ||
transaction: string | ||
} | ||
|
||
export const AggregateSigningSharesRequestSchema: yup.ObjectSchema<AggregateSigningSharesRequest> = | ||
yup | ||
.object({ | ||
publicKeyPackage: yup.string().defined(), | ||
unsignedTransaction: yup.string().defined(), | ||
signingPackage: yup.string().defined(), | ||
signingShares: yup | ||
.array( | ||
yup | ||
.object({ | ||
identifier: yup.string().defined(), | ||
signingShare: yup.string().defined(), | ||
}) | ||
.defined(), | ||
) | ||
.defined(), | ||
}) | ||
.defined() | ||
|
||
export const AggregateSigningSharesResponseSchema: yup.ObjectSchema<AggregateSigningSharesResponse> = | ||
yup | ||
.object({ | ||
transaction: yup.string().defined(), | ||
}) | ||
.defined() | ||
|
||
routes.register<typeof AggregateSigningSharesRequestSchema, AggregateSigningSharesResponse>( | ||
`${ApiNamespace.multisig}/aggregateSigningShares`, | ||
AggregateSigningSharesRequestSchema, | ||
(request, _context): void => { | ||
const unsigned = new UnsignedTransaction( | ||
Buffer.from(request.data.unsignedTransaction, 'hex'), | ||
) | ||
|
||
// TODO(hughy): change interface of signFrost to take Array of shares instead of Record | ||
const signingShares: Record<string, string> = {} | ||
for (const { identifier, signingShare } of request.data.signingShares) { | ||
signingShares[identifier] = signingShare | ||
} | ||
|
||
const transaction = unsigned.signFrost( | ||
request.data.publicKeyPackage, | ||
request.data.signingPackage, | ||
signingShares, | ||
) | ||
|
||
request.end({ | ||
transaction: transaction.toString('hex'), | ||
}) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters