@notabene/verify-proof 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -6
- package/src/bitcoin.ts +2 -3
- package/src/solana.ts +3 -4
- package/src/tests/solana.test.ts +2 -2
- package/dist/index.test.d.ts +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@notabene/verify-proof",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "Verify ownership proofs",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"type": "module",
|
@@ -25,7 +25,6 @@
|
|
25
25
|
"devDependencies": {
|
26
26
|
"eslint": "^9.9.0",
|
27
27
|
"microbundle": "^0.15.1",
|
28
|
-
"ox": "^0.2.2",
|
29
28
|
"typescript": "^5.5.4",
|
30
29
|
"vite": "^5.4.11",
|
31
30
|
"vitest": "^2.0.5"
|
@@ -33,10 +32,8 @@
|
|
33
32
|
"dependencies": {
|
34
33
|
"@bitauth/libauth": "^3.0.0",
|
35
34
|
"@notabene/javascript-sdk": "^2.0.2",
|
36
|
-
"@
|
37
|
-
"
|
38
|
-
"bigi": "^1.4.2",
|
39
|
-
"bs58": "^6.0.0",
|
35
|
+
"@scure/base": "^1.2.1",
|
36
|
+
"ox": "^0.2.2",
|
40
37
|
"tweetnacl": "^1.0.3",
|
41
38
|
"varuint-bitcoin": "^2.0.0"
|
42
39
|
}
|
package/src/bitcoin.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ProofStatus, SignatureProof } from "@notabene/javascript-sdk";
|
2
|
-
import { bech32 } from "bech32";
|
3
2
|
|
4
3
|
import {
|
5
4
|
secp256k1,
|
@@ -9,7 +8,7 @@ import {
|
|
9
8
|
encodeBase58AddressFormat,
|
10
9
|
} from "@bitauth/libauth";
|
11
10
|
import { encode as encodeLength } from "varuint-bitcoin";
|
12
|
-
import {
|
11
|
+
import { base64, bech32 } from "@scure/base";
|
13
12
|
|
14
13
|
enum SEGWIT_TYPES {
|
15
14
|
P2WPKH = "p2wpkh",
|
@@ -76,7 +75,7 @@ type DecodedSignature = {
|
|
76
75
|
};
|
77
76
|
|
78
77
|
function decodeSignature(proof: string): DecodedSignature {
|
79
|
-
const signature =
|
78
|
+
const signature = base64.decode(proof);
|
80
79
|
if (signature.length !== 65) throw new Error("Invalid signature length");
|
81
80
|
|
82
81
|
const flagByte = signature[0] - 27;
|
package/src/solana.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import nacl from "tweetnacl";
|
2
2
|
import { ProofStatus, SignatureProof } from "@notabene/javascript-sdk";
|
3
|
-
import {
|
4
|
-
import bs58 from "bs58";
|
3
|
+
import { base64, base58 } from "@scure/base";
|
5
4
|
|
6
5
|
export async function verifySolanaSignature(
|
7
6
|
proof: SignatureProof,
|
@@ -9,9 +8,9 @@ export async function verifySolanaSignature(
|
|
9
8
|
const [ns, _, address] = proof.address.split(/:/);
|
10
9
|
if (ns !== "solana") return { ...proof, status: ProofStatus.FAILED };
|
11
10
|
try {
|
12
|
-
const publicKey =
|
11
|
+
const publicKey = base58.decode(address);
|
13
12
|
const messageBytes = new TextEncoder().encode(proof.attestation);
|
14
|
-
const signatureBytes =
|
13
|
+
const signatureBytes = base64.decode(proof.proof);
|
15
14
|
const verified = nacl.sign.detached.verify(
|
16
15
|
messageBytes,
|
17
16
|
signatureBytes,
|
package/src/tests/solana.test.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
2
|
-
import
|
2
|
+
import { base58 } from "@scure/base";
|
3
3
|
import nacl from "tweetnacl";
|
4
4
|
import {
|
5
5
|
ProofStatus,
|
@@ -10,7 +10,7 @@ import { verifySolanaSignature } from "../solana";
|
|
10
10
|
|
11
11
|
describe("verifySolanaSignature", () => {
|
12
12
|
const keypair = nacl.sign.keyPair();
|
13
|
-
const address =
|
13
|
+
const address = base58.encode(keypair.publicKey);
|
14
14
|
it("verifies valid Solana signature", async () => {
|
15
15
|
// Generate a test keypair
|
16
16
|
const message = "Test message";
|
package/dist/index.test.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|