Skip to content
Merged
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
23 changes: 23 additions & 0 deletions proto/tm2/multisig.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";
package tm;

option go_package = "github.com/gnolang/gno/tm2/pkg/crypto/multisig/pb";

// imports
import "google/protobuf/any.proto";

// messages
message PubKeyMultisig {
uint64 k = 1 [json_name = "threshold"];
repeated google.protobuf.Any pub_keys = 2 [json_name = "pubkeys"];
}

message Multisignature {
CompactBitArray bit_array = 1;
repeated bytes sigs = 2;
}

message CompactBitArray {
uint32 extra_bits_stored = 1 [json_name = "extra_bits"]; // The number of extra bits in elems.
bytes elems = 2 [json_name = "bits"];
}
2 changes: 1 addition & 1 deletion src/proto/google/protobuf/any.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/proto/tm2/abci.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/proto/tm2/multisig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { bytesToHex } from '@noble/hashes/utils';
import { CompactBitArray } from './multisig';

describe('TestMarshalCompactBitArrayAmino', () => {
const testCases = [
{ marshalledBA: `null`, hexOutput: '' },
{ marshalledBA: `null`, hexOutput: '' },
{ marshalledBA: `"_"`, hexOutput: '0801120100' },
{ marshalledBA: `"x"`, hexOutput: '0801120180' },
{ marshalledBA: `"xx___"`, hexOutput: '08051201c0' },
{ marshalledBA: `"xx______x"`, hexOutput: '08011202c080' },
{ marshalledBA: `"xx_____________x"`, hexOutput: '1202c001' },
];

test.each(testCases)('$marshalledBA', async ({ marshalledBA, hexOutput }) => {
// Parse JSON into CompactBitArray
const jsonData = JSON.parse(marshalledBA);
const bA = CompactBitArray.fromJSON(jsonData);

// Marshal using Amino
const bz = CompactBitArray.encode(bA).finish();

// Convert bytes to hex and compare
const actualHex = bytesToHex(bz);
expect(actualHex).toBe(hexOutput);
});
});
Loading