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

Multisig test #1012

Open
wants to merge 2 commits into
base: sign-tx-multisig
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions sigma-js/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/** @type {import("jest").Config} */
const config = {
transform: {}, // reduce non-cached test time by about 20x by disabling babel code transformation
moduleDirectories: ["<rootDir>/node_modules"],
moduleNameMapper: {
"sigmastate-js/main":
"<rootDir>/../sc/js/target/scala-2.13/sc-fastopt/main.js",
},
transform: {}, // reduce non-cached test time by about 20x by disabling babel code transformation
moduleDirectories: ["<rootDir>/node_modules"],
moduleNameMapper: {
"sigmastate-js/main":
"<rootDir>/../sc/js/target/scala-2.13/sc-fastopt/main.js",
},
};

module.exports = config;
553 changes: 363 additions & 190 deletions sigma-js/package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions sigma-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
"ci:snapshot": "node ./scripts/setSnapshotVersion"
},
"dependencies": {
"@noble/hashes": "1.1.4",
"@fleet-sdk/common": "0.1.3",
"sigmajs-crypto-facade": "0.0.7"
"@fleet-sdk/core": "^0.4.1",
"@noble/hashes": "1.1.4",
"bip39": "^3.1.0",
"sigmajs-crypto-facade": "^0.0.7"
},
"devDependencies": {
"jest": "^29.0.3",
Expand Down
194 changes: 194 additions & 0 deletions sigma-js/tests/data/headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
const headers = [
{
id: '24587f75221fae3b672c735c70167928c5aef775cbd0e67e01c195735f824afe',
parentId: '10f7f78bd141a6a2cb8db90ec357648e21160f3bf896f26223db2cfaa87b1a3f',
version: 3,
timestamp: 1717863621391,
height: 1282256,
nBits: 117775526,
votes: '080000',
stateRoot: 'fc7dc6c7715127d38cbc16bdb909ff53a551fe88f0dd5bbbda669e55d9f968841a',
adProofsRoot: 'b5fded4d869c315a296503f2e624682343d55888a46429940b5bc2b29a55444b',
transactionsRoot: '973948f6d681294715a4f022b0c03c68cd32a7a1a668292e19fcd789a34eb43a',
extensionHash: '3ecf5d2666105adaf60c14f481d84c46dadf083ad7004ad0bb0c43b0a153793e',
powSolutions: {
pk: '03677d088e4958aedcd5cd65845540e91272eba99e4d98e382f5ae2351e0dfbefd',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'b5299a003629f80a',
d: '0',
},
},
{
id: '10f7f78bd141a6a2cb8db90ec357648e21160f3bf896f26223db2cfaa87b1a3f',
parentId: '394c7f3ae4269c06172706a68283c6067397360b31d5cd7c4bc53c2172b64897',
version: 3,
timestamp: 1717863408312,
height: 1282255,
nBits: 117775526,
votes: '080000',
stateRoot: 'ae566d8272662fe82de4378c53bed81e65268f0d5389880cc126e074026bae861a',
adProofsRoot: '34d602ec597ff48ff3deb727f821f90cc4645043be931ebdd449748ce94e22dc',
transactionsRoot: '824a8153966ff1f6c5811364cd49b33ca0b0668bf508b330d0818aa4f6ffc6a1',
extensionHash: '3ecf5d2666105adaf60c14f481d84c46dadf083ad7004ad0bb0c43b0a153793e',
powSolutions: {
pk: '03677d088e4958aedcd5cd65845540e91272eba99e4d98e382f5ae2351e0dfbefd',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: '95c02200a8e11d2e',
d: '0',
},
},
{
id: '394c7f3ae4269c06172706a68283c6067397360b31d5cd7c4bc53c2172b64897',
parentId: 'c672c0e9975f30b6d61931e4a3f4317174e19803b98fdc04b61bcaee44028dd6',
version: 3,
timestamp: 1717863344401,
height: 1282254,
nBits: 117775526,
votes: '000000',
stateRoot: '4a5401412138ed7a6a1f1df1706bcb2e36e1df4636581564312f4af23cba0b301a',
adProofsRoot: 'aa3af334320392f6a7a28b8dd8a8091b7242bdb64a5d47f17ed1dcdedf6501ba',
transactionsRoot: '4287a17eceb9678599d04c3325d7fa0db36ff0b85678be9dba566bb294a66cc8',
extensionHash: '3ecf5d2666105adaf60c14f481d84c46dadf083ad7004ad0bb0c43b0a153793e',
powSolutions: {
pk: '0223b461fab0b119677449b56760cb01586fc38b007764d4744e14a2da270322b5',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: '827fbb53377434f2',
d: '0',
},
},
{
id: 'c672c0e9975f30b6d61931e4a3f4317174e19803b98fdc04b61bcaee44028dd6',
parentId: '9e8e8584f9fd9653eb5976f1fc167753186a98a0438a6ae704b42c8697d4cecd',
version: 3,
timestamp: 1717863147263,
height: 1282253,
nBits: 117775526,
votes: '000000',
stateRoot: 'd34a28b1310d75200ea6a0c90e009b80f8dd2963f1e06ecffbacde4f42a3bfee1a',
adProofsRoot: 'e372fbb17ba24658f9e1ce643641a841efcd602e1c41790aefef973cd433ce9b',
transactionsRoot: 'ef23b2d71ca9489b46cb5251640010e27e34fa029a95b570c6c124a4173f684c',
extensionHash: 'b9be518371b867df5ac82a06443991ed8bf9306ebf55a7434b15210df9a0c539',
powSolutions: {
pk: '0295facb78290ac2b55f1453204d49df37be5bae9f185ed6704c1ba3ee372280c1',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'a1c10009e3a315f2',
d: '0',
},
},
{
id: '9e8e8584f9fd9653eb5976f1fc167753186a98a0438a6ae704b42c8697d4cecd',
parentId: 'd01f8967ca6bcd7aa13af207fc6ed6a8acb57b4074ec4392668a66fe781bfb23',
version: 3,
timestamp: 1717863122763,
height: 1282252,
nBits: 117775526,
votes: '000000',
stateRoot: '284e3943db7649c2b2a325e35a812ed346f32e18a31fc2eaaaf6b4b2f643ebfe1a',
adProofsRoot: '2f5f690a07c5d5cfd5dae197e542cecc8dc52ae18447c36a8968532df83fcc7b',
transactionsRoot: '98a15004c5e34a3ce209bd61eb328cf9ab7821d4804e0d5e2776a124d0545200',
extensionHash: 'b9be518371b867df5ac82a06443991ed8bf9306ebf55a7434b15210df9a0c539',
powSolutions: {
pk: '02eeec374f4e660e117fccbfec79e6fe5cdf44ac508fa228bfc654d2973f9bdc9a',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'e13800048268ca56',
d: '0',
},
},
{
id: 'd01f8967ca6bcd7aa13af207fc6ed6a8acb57b4074ec4392668a66fe781bfb23',
parentId: '9a380a48131925a260f613659b34492a9b8ff7eb39f98aad4987079db203ef4d',
version: 3,
timestamp: 1717862773912,
height: 1282251,
nBits: 117775526,
votes: '000000',
stateRoot: 'c09c380b054005326e8b4f122da6b1e9d9ddf45be3f5c1a1d3d4b3e9253592a01a',
adProofsRoot: '8680e6c0d0fe1e017c39ceda3c619ea7850e72f81885174dbc9b0bef7d74456e',
transactionsRoot: '99d630ae8ead0ee7e68caa4caf21967a70b1e586c4613fe08a1ed37ab9fa32f5',
extensionHash: '8d45e1653f21750f583b53ec970d3f828e92501483b9471693794e18fbcaf8cf',
powSolutions: {
pk: '0295facb78290ac2b55f1453204d49df37be5bae9f185ed6704c1ba3ee372280c1',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'a4d20018a87b8a4a',
d: '0',
},
},
{
id: '9a380a48131925a260f613659b34492a9b8ff7eb39f98aad4987079db203ef4d',
parentId: '83a8eade82a6d71c6e42a6bd22d713c49809b3f8a2874ef6b691346f2bd2da58',
version: 3,
timestamp: 1717862705685,
height: 1282250,
nBits: 117775526,
votes: '000000',
stateRoot: 'd066847f4f30064b29aaa901717dcf4f2500c446622af666bbc9af5066fff2991a',
adProofsRoot: 'a09323112a35ce2210732482dfb3d9135b8799b0ea1d9decdc801dea271c69b0',
transactionsRoot: 'f643de048397d12b1c58579f23fb55cdfe9ce74d66ab899024b8557e44ff5769',
extensionHash: 'ea48106638079bd93c6124af301c1ace2be76d9275c6cf82a60adea21185fcc5',
powSolutions: {
pk: '0274e729bb6615cbda94d9d176a2f1525068f12b330e38bbbf387232797dfd891f',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: '65fe0004e59d407a',
d: '0',
},
},
{
id: '83a8eade82a6d71c6e42a6bd22d713c49809b3f8a2874ef6b691346f2bd2da58',
parentId: '31ea3b11d226c1c2ffe3ed52ed467aa89fe69c648422b920c4a6795b5bc3f261',
version: 3,
timestamp: 1717862655809,
height: 1282249,
nBits: 117775526,
votes: '080000',
stateRoot: 'b94b0cd75a8ced75435bf646b142699774b7719a7dc6d7bf3521231707883a4c1a',
adProofsRoot: 'eb40c786a40450f371ae379c1dc3431d8ea1f30e8e3a134e171d4792bbe106c2',
transactionsRoot: 'af8c49a0e721076de8c35fecc1ba450b52a581875bd9b4ac3756d5453b0b70f8',
extensionHash: '987952f8d2eba20163aab8fdfe71f9a2c900f7757862ddcf8402552cc1988b99',
powSolutions: {
pk: '03677d088e4958aedcd5cd65845540e91272eba99e4d98e382f5ae2351e0dfbefd',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'dd4138c023ae6df4',
d: '0',
},
},
{
id: '31ea3b11d226c1c2ffe3ed52ed467aa89fe69c648422b920c4a6795b5bc3f261',
parentId: '67d045e914359c8934d205ef05818688944d94cb4c211032e7fe48f21e4f9762',
version: 3,
timestamp: 1717862652982,
height: 1282248,
nBits: 117775526,
votes: '080000',
stateRoot: '113aaf2565e6b5879adb961d43920f1c772789af58758fe57cf71ebbc1c2e43d1a',
adProofsRoot: 'c01fa3201e7cf0e6c4b63c32d8e3d84dd4850101d6d10a6e0e6540b8bdb09ac3',
transactionsRoot: 'e8e91d37c7c376a36947a487a5fa3404565f6146b5e41837ab11d74ffe0a8a11',
extensionHash: '9845d1f3409b51c3a61300b8119955caf086b0e497cd67ee08f7167212615bff',
powSolutions: {
pk: '03677d088e4958aedcd5cd65845540e91272eba99e4d98e382f5ae2351e0dfbefd',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: '6ce31b4000e2a1f8',
d: '0',
},
},
{
id: '67d045e914359c8934d205ef05818688944d94cb4c211032e7fe48f21e4f9762',
parentId: 'b4d4bd706d385ae3a2d090ce9ede579f481bd0b4f8f116a508e73f682054ab23',
version: 3,
timestamp: 1717862631198,
height: 1282247,
nBits: 117775526,
votes: '080000',
stateRoot: '71d8ea5a2d1fb9bee68acca4cac30bbb15eb67304856027e5c7567b4e801ba6f1a',
adProofsRoot: '23cb8d94d01428e692ebcbe0ad42c4b67ff0a2f4c2b924a0b09435f1a284d9ab',
transactionsRoot: 'dec521e86dcee6830e85a72df206f850b05361cfc17d2ade42af1fdbf21c24e6',
extensionHash: '5c623cf8cf41ec7f48f3e296f8e620f085e26552481bdacec672e0c5e8acc9c2',
powSolutions: {
pk: '03677d088e4958aedcd5cd65845540e91272eba99e4d98e382f5ae2351e0dfbefd',
w: '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
n: 'b8daa6001046f503',
d: '0',
},
},
];

module.exports = headers;
21 changes: 21 additions & 0 deletions sigma-js/tests/data/info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//https://api.ergoplatform.com/api/v1/info
const info = {
lastBlockId: '5b9b19ac028c6956b4cdf8ec75227934b8134ff3635ed3aceac8a8bf20788dce',
height: 1282261,
maxBoxGix: 6197269,
maxTxGix: 1167892,
params: {
height: 506880,
storageFeeFactor: 1250000,
minValuePerByte: 360,
maxBlockSize: 1271009,
maxBlockCost: 7030268,
blockVersion: 2,
tokenAccessCost: 100,
inputCost: 2000,
dataInputCost: 100,
outputCost: 100,
},
};

module.exports = info;
70 changes: 70 additions & 0 deletions sigma-js/tests/data/unsignedTrasactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const poolToAliceTx = {
inputs: [
{
boxId: "fe4daef7e5eaa2bb93013d94c1ae78c272d9ac11e9b1d4e1f515405ef2668de8",
value: "5000000000",
ergoTree:
"0008cd02f8bf1ab71f755192e39eb54fe4e7de5362ce618f9ac04550b96f87b0e674ed7c",
creationHeight: 1280810,
assets: [
{
tokenId:
"5bf691fbf0c4b17f8f8cece83fa947f62f480bfbd242bd58946f85535125db4d",
amount: "100000000000000",
},
{
tokenId:
"f60bff91f7ae3f3a5f0c2d35b46ef8991f213a61d7f7e453d344fa52a42d9f9a",
amount: "500000000",
},
],
additionalRegisters: {},
transactionId:
"2194af861e036f3a7012a6efda33686b32a7fffe188ae408a291cdb0fd7dcb4e",
index: 0,
extension: {},
},
],
dataInputs: [],
outputs: [
{
value: "1000000",
ergoTree:
"0008cd034e8a84ced7cfe5a25d7914c600a0cdb7e8117c175aff93b0a76b0902e8d777d4",
creationHeight: 1282261,
assets: [],
additionalRegisters: {},
},
{
value: "1000000",
ergoTree:
"1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304",
creationHeight: 1282261,
assets: [],
additionalRegisters: {},
},
{
value: "4998000000",
ergoTree:
"0008cd02f8bf1ab71f755192e39eb54fe4e7de5362ce618f9ac04550b96f87b0e674ed7c",
creationHeight: 1282261,
assets: [
{
tokenId:
"5bf691fbf0c4b17f8f8cece83fa947f62f480bfbd242bd58946f85535125db4d",
amount: "100000000000000",
},
{
tokenId:
"f60bff91f7ae3f3a5f0c2d35b46ef8991f213a61d7f7e453d344fa52a42d9f9a",
amount: "500000000",
},
],
additionalRegisters: {},
},
],
};

module.exports = {
poolToAliceTx
}
19 changes: 19 additions & 0 deletions sigma-js/tests/data/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const ALICE_MNEMONIC =
'swim current hurry local faint obey scare vessel inch chest lock paddle since world agree1';
const BOB_MNEMONIC =
'grit sorry wise village fork movie kingdom trend jar grant icon equal vessel case nominee';
const POOL_MNEMONIC =
'phrase belt winner top helmet satoshi unfold gas little until choose hurt rough minute name';

const ALICE_ADDRESS = '9h4PvCt8B4ZJtzmpneRwatFwufMgTSLm8UXK2waxuHhgZjLZkgK';
const BOB_ADDRESS = '9hh35g9W39kSKFuScYaLC7XqU8nunb3kmPXjwVkCyUsdx6ZdVnJ';
const POOL_ADDRESS = '9gQcQmLujhaWzyLxaRPKq1Fu5H9uAeikxiudRLiz9TmzBCixGo4';

module.exports = {
ALICE_MNEMONIC,
BOB_MNEMONIC,
POOL_MNEMONIC,
ALICE_ADDRESS,
BOB_ADDRESS,
POOL_ADDRESS
}
42 changes: 42 additions & 0 deletions sigma-js/tests/data/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { AvlTree$, GroupElement$ } = require('sigmastate-js/main');

function blockchainParameterFromErgoNodeIfo(info){
return{
storageFeeFactor: info.params.storageFeeFactor,
minValuePerByte: info.params.minValuePerByte,
maxBlockSize: info.params.maxBlockSize,
tokenAccessCost: info.params.tokenAccessCost,
inputCost: info.params.inputCost,
dataInputCost: info.params.dataInputCost,
outputCost: info.params.outputCost,
maxBlockCost: info.params.maxBlockCost,
softForkStartingHeight: 100,
softForkVotesCollected: 50,
blockVersion: info.params.blockVersion,
}
};

function sigmastateHeader(header){
return {
id: header.id,
version: header.version,
parentId: header.parentId,
ADProofsRoot: header.adProofsRoot,
stateRoot: AvlTree$.fromDigest(header.stateRoot),
transactionsRoot: header.transactionsRoot,
timestamp: header.timestamp,
nBits: header.nBits,
height: header.height,
extensionRoot: header.extensionHash,
minerPk: GroupElement$.fromPointHex(header.powSolutions.pk),
powOnetimePk: GroupElement$.fromPointHex(header.powSolutions.w),
powNonce: header.powSolutions.n,
powDistance: BigInt(header.powSolutions.d),
votes: header.votes,
};
}

module.exports = {
blockchainParameterFromErgoNodeIfo,
sigmastateHeader
}
Loading
Loading