Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Dependency directories (remove the comment below to include it)
# vendor/
node_modules/
bun.lock

# Go workspace file
go.work
Expand Down
38 changes: 31 additions & 7 deletions brc100frames/acquire-certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const SubjectPubKeyHex = "025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a
const CertifierPubKeyHex = "0294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a1";
const TypeBase64 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGU=";
const SerialNumberBase64 = "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=";
const RevocationOutpoint = "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0";

export const acquireCertificate: Record<string, ReturnType<typeof generateWireFramesFor>> = {
'acquireCertificate-simple': generateWireFramesFor(
Expand All @@ -15,24 +16,47 @@ export const acquireCertificate: Record<string, ReturnType<typeof generateWireFr
serialNumber: SerialNumberBase64,
subject: SubjectPubKeyHex,
certifier: CertifierPubKeyHex,
revocationOutpoint: "txid123:0",
revocationOutpoint: RevocationOutpoint,
fields: {email: "alice@example.com", name: "Alice"}, // Alphabetical
signature: "sig-hex",
// signature pk = 95c5931552e547d72a292e9d6f59eef2b9f7e1576d8c7b49731b505117c0cdfa, msg = test message
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
} as AcquireCertificateResult,
{
// Args object (WalletAcquireCertificateArgs) - JSON format
type: TypeBase64,
certifier: CertifierPubKeyHex,
acquisitionProtocol: "issuance",
acquisitionProtocol: "direct",
fields: {email: "alice@example.com", name: "Alice"}, // Alphabetical
serialNumber: SerialNumberBase64,
revocationOutpoint: "txid123:0",
signature: "sig-hex",
certifierUrl: "https://certifier.example.com",
keyringRevealer: "revealer-key-hex", // Assuming this is a string ID/hex
revocationOutpoint: RevocationOutpoint,
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
keyringRevealer: "025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf79097",
keyringForSubject: {field1: "key1", field2: "key2"},
privileged: false,
} as AcquireCertificateArgs
),
'acquireCertificate-issuance': generateWireFramesFor(
'acquireCertificate',
{
// Result object (WalletCertificate) - JSON format
type: TypeBase64,
serialNumber: SerialNumberBase64,
subject: SubjectPubKeyHex,
certifier: CertifierPubKeyHex,
revocationOutpoint: RevocationOutpoint,
fields: {email: "alice@example.com", name: "Alice"}, // Alphabetical
// signature pk = 95c5931552e547d72a292e9d6f59eef2b9f7e1576d8c7b49731b505117c0cdfa, msg = test message
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
} as AcquireCertificateResult,
{
// Args object (WalletAcquireCertificateArgs) - JSON format
type: TypeBase64,
certifier: CertifierPubKeyHex,
acquisitionProtocol: "issuance",
fields: {email: "alice@example.com", name: "Alice"}, // Alphabetical
certifierUrl: "https://certifier.example.com",
privileged: false,
} as AcquireCertificateArgs
),
// Add more cases if needed
}
5 changes: 4 additions & 1 deletion brc100frames/create-hmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export const createHmac: Record<string, ReturnType<typeof generateWireFramesFor>
'createHmac-simple': generateWireFramesFor(
'createHmac',
{
hmac: [50, 60, 70, 80, 90, 100, 110, 120],
hmac: [50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120],
},
{
protocolID: [1 /* SecurityLevelEveryApp */, 'test-protocol'],
Expand Down
2 changes: 1 addition & 1 deletion brc100frames/create-signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createSignature: Record<string, ReturnType<typeof generateWireFrame
'createSignature',
{
// Byte array representation for wire encoding
signature: hexToBytes("302502204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd41020100"),
signature: hexToBytes("302502204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd41020101"),
},
{
protocolID: [1 /* SecurityLevelEveryApp */, 'test-protocol'],
Expand Down
6 changes: 3 additions & 3 deletions brc100frames/discover-by-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const discoverByAttributes: Record<string, ReturnType<typeof generateWire
serialNumber: "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
subject: pubKeyHex,
certifier: CounterpartyHex,
revocationOutpoint: "txid123:0",
revocationOutpoint: "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
fields: {"name": "Alice", "email": "alice@example.com"},
signature: "7369676e61747572652d686578",
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",

// IdentityCertificate specific fields
certifierInfo: {
Expand All @@ -28,7 +28,7 @@ export const discoverByAttributes: Record<string, ReturnType<typeof generateWire
description: "Certifier description",
trust: 5,
},
publiclyRevealedKeyring: {"pubField": "pubKey"},
publiclyRevealedKeyring: {"pubField": "AlrUOiKsONC8H4usqrsyO11jRwO3p3TEJo9qCeTd95CX"},
decryptedFields: {"name": "Alice"},
}
]
Expand Down
6 changes: 3 additions & 3 deletions brc100frames/discover-by-identity-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const discoverByIdentityKey: Record<string, ReturnType<typeof generateWir
serialNumber: "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
subject: pubKeyHex,
certifier: CounterpartyHex,
revocationOutpoint: "txid123:0",
revocationOutpoint: "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
fields: {"name": "Alice", "email": "alice@example.com"},
signature: "7369676e61747572652d686578",
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",

// IdentityCertificate specific fields
certifierInfo: {
Expand All @@ -28,7 +28,7 @@ export const discoverByIdentityKey: Record<string, ReturnType<typeof generateWir
description: "Certifier description",
trust: 5,
},
publiclyRevealedKeyring: {"pubField": "pubKey"},
publiclyRevealedKeyring: {"pubField": "AlrUOiKsONC8H4usqrsyO11jRwO3p3TEJo9qCeTd95CX"},
decryptedFields: {"name": "Alice"},
}
]
Expand Down
3 changes: 1 addition & 2 deletions brc100frames/generator/wire-frames-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ export async function generateWireFramesFor<
}

function frameNumbersToHex(numbers: number[]): string {
const body = new Uint8Array(numbers)
return Array.from(body, byte => byte.toString(16).padStart(2, '0')).join('');
return Array.from(numbers, num => num.toString(16).padStart(2, '0')).join('');
}
1 change: 0 additions & 1 deletion brc100frames/get-public-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const getPublicKey: Record<string, ReturnType<typeof generateWireFramesFo
privileged: true,
privilegedReason: "privileged reason",
seekPermission: true,
identityKey: true,
}
),
// Add more cases if needed
Expand Down
6 changes: 3 additions & 3 deletions brc100frames/internalize-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const internalizeAction: Record<string, ReturnType<typeof generateWireFra
outputIndex: 0,
protocol: "wallet payment",
paymentRemittance: {
derivationPrefix: "prefix",
derivationSuffix: "suffix",
senderIdentityKey: "sender-key",
derivationPrefix: "prefix", // "prefix"
derivationSuffix: "suffix", // "suffix"
senderIdentityKey: "03b106dae20ae8fca0f4e8983d974c4b583054573eecdcdcfad261c035415ce1ee",
}
}, {
outputIndex: 1,
Expand Down
37 changes: 32 additions & 5 deletions brc100frames/list-certificates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {generateWireFramesFor} from "./generator/wire-frames-generator";
import {ListCertificatesArgs, ListCertificatesResult} from "@bsv/sdk";

// Define the keys used in the test cases
const pubKeyHex = "025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf79097";
Expand All @@ -17,24 +18,50 @@ export const listCertificates: Record<string, ReturnType<typeof generateWireFram
serialNumber: "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
subject: pubKeyHex,
certifier: CounterpartyHex,
revocationOutpoint: "txid123:0",
revocationOutpoint: "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
fields: {"name": "Alice", "email": "alice@example.com"},
signature: "7369676e61747572652d686578", // hex for "signature-hex"
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
}
]
} as ListCertificatesResult,
{ // Args object definition
certifiers: [CounterpartyHex, VerifierHex],
types: ["dGVzdC10eXBlMSAgICAgICAgICAgICAgICAgICAgICA=", "dGVzdC10eXBlMiAgICAgICAgICAgICAgICAgICAgICA="],
limit: 5,
offset: 0,
privileged: true,
privilegedReason: "list-cert-reason",
} as ListCertificatesArgs
),
'listCertificates-full': generateWireFramesFor(
'listCertificates', // Corresponds to the Go function/substrate call
{ // Result object definition
totalCertificates: 1,
certificates: [
{
// Certificate fields
type: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGU=",
serialNumber: "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
subject: pubKeyHex,
certifier: CounterpartyHex,
revocationOutpoint: "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
fields: {"name": "Alice", "email": "alice@example.com"},
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",

// CertificateResult specific fields
keyring: {"field1": "key1", "field2": "key2"},
verifier: VerifierHex,
}
]
},
} as ListCertificatesResult,
{ // Args object definition
certifiers: [CounterpartyHex, VerifierHex],
types: ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGUx", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGUy"],
types: ["dGVzdC10eXBlMSAgICAgICAgICAgICAgICAgICAgICA=", "dGVzdC10eXBlMiAgICAgICAgICAgICAgICAgICAgICA="],
limit: 5,
offset: 0,
privileged: true,
privilegedReason: "list-cert-reason",
}
} as ListCertificatesArgs
),
// Add more test cases here if needed
}
2 changes: 1 addition & 1 deletion brc100frames/list-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const listOutputs: Record<string, ReturnType<typeof generateWireFramesFor
outpoint: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef.0",
}, {
satoshis: 5000,
spendable: false,
spendable: true,
outpoint: "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890.2",
}]
},
Expand Down
8 changes: 4 additions & 4 deletions brc100frames/prove-certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const proveCertificate: Record<string, ReturnType<typeof generateWireFram
'proveCertificate-simple': generateWireFramesFor(
'proveCertificate',
{ // Result object definition
keyringForVerifier: {"name": "name-key"},
keyringForVerifier: {"name": "bmFtZS1rZXk="},
} as ProveCertificateResult,
{ // Args object definition
certificate: {
Expand All @@ -19,9 +19,9 @@ export const proveCertificate: Record<string, ReturnType<typeof generateWireFram
serialNumber: "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
subject: pubKeyHex,
certifier: CounterpartyHex,
revocationOutpoint: "txid123:0",
fields: {"name": "Alice", "email": "alice@example.com"},
signature: "7369676e61747572652d686578", // hex for "signature-hex"
revocationOutpoint: "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
fields: {"email": "alice@example.com", "name": "Alice"}, // Fields must be alphabetically ordered for serialization to match exactly
signature: "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
},
// ProveCertificateArgs specific fields
fieldsToReveal: ["name"],
Expand Down
5 changes: 4 additions & 1 deletion brc100frames/verify-hmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const verifyHmac: Record<string, ReturnType<typeof generateWireFramesFor>
privilegedReason: 'test reason',
seekPermission: true,
data: [10, 20, 30, 40],
hmac: [50, 60, 70, 80, 90, 100, 110, 120],
hmac: [50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120,
50, 60, 70, 80, 90, 100, 110, 120],
}
),
// Add more cases if needed
Expand Down
2 changes: 1 addition & 1 deletion brc100frames/verify-signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const verifySignature: Record<string, ReturnType<typeof generateWireFrame
privilegedReason: 'test reason',
seekPermission: true,
data: [11, 22, 33, 44],
signature: hexToBytes("302502204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd41020100"),
signature: hexToBytes("302502204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd41020101"),
// hashToDirectlyVerify: undefined, // Omitting for simple test
}
),
Expand Down
14 changes: 14 additions & 0 deletions generated/brc100/acquireCertificate-issuance-args.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"json": {
"type": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGU=",
"certifier": "0294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a1",
"acquisitionProtocol": "issuance",
"fields": {
"email": "alice@example.com",
"name": "Alice"
},
"certifierUrl": "https://certifier.example.com",
"privileged": false
},
"wire": "11000000000000000000000000000000000000000000000000746573742d747970650294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a10205656d61696c11616c696365406578616d706c652e636f6d046e616d6505416c69636500ff021d68747470733a2f2f6365727469666965722e6578616d706c652e636f6d"
}
15 changes: 15 additions & 0 deletions generated/brc100/acquireCertificate-issuance-result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"json": {
"type": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGU=",
"serialNumber": "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
"subject": "025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf79097",
"certifier": "0294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a1",
"revocationOutpoint": "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
"fields": {
"email": "alice@example.com",
"name": "Alice"
},
"signature": "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a"
},
"wire": "000000000000000000000000000000000000000000000000746573742d747970650000000000000000000000000000746573742d73657269616c2d6e756d626572025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf790970294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a1aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d000205656d61696c11616c696365406578616d706c652e636f6d046e616d6505416c6963653045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a"
}
11 changes: 5 additions & 6 deletions generated/brc100/acquireCertificate-simple-args.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
"json": {
"type": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXN0LXR5cGU=",
"certifier": "0294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a1",
"acquisitionProtocol": "issuance",
"acquisitionProtocol": "direct",
"fields": {
"email": "alice@example.com",
"name": "Alice"
},
"serialNumber": "AAAAAAAAAAAAAAAAAAB0ZXN0LXNlcmlhbC1udW1iZXI=",
"revocationOutpoint": "txid123:0",
"signature": "sig-hex",
"certifierUrl": "https://certifier.example.com",
"keyringRevealer": "revealer-key-hex",
"revocationOutpoint": "aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d.0",
"signature": "3045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a",
"keyringRevealer": "025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf79097",
"keyringForSubject": {
"field1": "key1",
"field2": "key2"
},
"privileged": false
},
"wire": "11000000000000000000000000000000000000000000000000746573742d747970650294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a10205656d61696c11616c696365406578616d706c652e636f6d046e616d6505416c69636500ff021d68747470733a2f2f6365727469666965722e6578616d706c652e636f6d"
"wire": "11000000000000000000000000000000000000000000000000746573742d747970650294c479f762f6baa97fbcd4393564c1d7bd8336ebd15928135bbcf575cd1a71a10205656d61696c11616c696365406578616d706c652e636f6d046e616d6505416c69636500ff010000000000000000000000000000746573742d73657269616c2d6e756d626572aec245f27b7640c8b1865045107731bfb848115c573f7da38166074b1c9e475d00473045022100a6f09ee70382ab364f3f6b040aebb8fe7a51dbc3b4c99cfeb2f7756432162833022067349b91a6319345996faddf36d1b2f3a502e4ae002205f9d2db85474f9aed5a025ad43a22ac38d0bc1f8bacaabb323b5d634703b7a774c4268f6a09e4ddf7909702066669656c64310391ecb5066669656c64320391ecb6"
}
Loading
Loading