Merge pull request #122 from confio/new-secp-sig-constructor

Remove obsolete makeSecp256k1SignatureFromFixedLength
This commit is contained in:
Simon Warta 2020-02-24 09:51:27 +01:00 committed by GitHub
commit f04de9fdf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 66 deletions

View File

@ -39,9 +39,9 @@
},
"dependencies": {
"@cosmwasm/sdk": "^0.0.8",
"@iov/bcp": "^2.0.2",
"@iov/crypto": "^2.0.2",
"@iov/encoding": "^2.0.2",
"@iov/bcp": "^2.1.0",
"@iov/crypto": "^2.1.0",
"@iov/encoding": "^2.1.0",
"@iov/stream": "^2.0.2",
"@iov/utils": "^2.0.2",
"bn.js": "^5.1.1",
@ -50,7 +50,7 @@
"xstream": "^11.11.0"
},
"devDependencies": {
"@iov/keycontrol": "^2.0.2",
"@iov/keycontrol": "^2.1.0",
"@types/bn.js": "^4.11.6"
}
}

View File

@ -1,4 +1,4 @@
import { decodeSignature, makeSecp256k1SignatureFromFixedLength } from "@cosmwasm/sdk";
import { decodeSignature } from "@cosmwasm/sdk";
import {
Account,
Address,
@ -17,7 +17,7 @@ import {
TransactionState,
UnsignedTransaction,
} from "@iov/bcp";
import { Random, Secp256k1, Sha256 } from "@iov/crypto";
import { Random, Secp256k1, Secp256k1Signature, Sha256 } from "@iov/crypto";
import { Bech32, Encoding } from "@iov/encoding";
import { HdPaths, Secp256k1HdWallet, UserProfile } from "@iov/keycontrol";
import { assert } from "@iov/utils";
@ -475,7 +475,7 @@ describe("CosmWasmConnection", () => {
const { pubkey, signature } = decodeSignature(encodeFullSignature(signatures[0]));
const prehashed = new Sha256(signBytes).digest();
const valid = await Secp256k1.verifySignature(
makeSecp256k1SignatureFromFixedLength(signature),
Secp256k1Signature.fromFixedLength(signature),
prehashed,
pubkey,
);

View File

@ -37,8 +37,8 @@
],
"dependencies": {
"@cosmwasm/sdk": "^0.0.8",
"@iov/crypto": "^2.0.2",
"@iov/encoding": "^2.0.2",
"@iov/crypto": "^2.1.0",
"@iov/encoding": "^2.1.0",
"@iov/utils": "^2.0.2",
"argparse": "^1.0.10",
"babylon": "^6.18.0",

View File

@ -36,10 +36,10 @@
},
"dependencies": {
"@cosmwasm/bcp": "^0.0.8",
"@iov/bcp": "^2.0.2",
"@iov/crypto": "^2.0.2",
"@iov/encoding": "^2.0.2",
"@iov/keycontrol": "^2.0.2",
"@iov/bcp": "^2.1.0",
"@iov/crypto": "^2.1.0",
"@iov/encoding":"^2.1.0",
"@iov/keycontrol": "^2.1.0",
"@iov/utils": "^2.0.2",
"@koa/cors": "^3.0.0",
"axios": "^0.19.0",

View File

@ -38,15 +38,13 @@
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js"
},
"dependencies": {
"@iov/crypto": "^2.0.2",
"@iov/encoding": "^2.0.2",
"@iov/crypto": "^2.1.0",
"@iov/encoding": "^2.1.0",
"@iov/utils": "^2.0.2",
"axios": "^0.19.0",
"bn.js": "^5.1.1",
"pako": "^1.0.11"
},
"devDependencies": {
"@types/bn.js": "^4.11.6",
"@types/pako": "^1.0.1",
"readonly-date": "^1.0.0"
}

View File

@ -24,11 +24,7 @@ export {
encodeSecp256k1Pubkey,
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export {
encodeSecp256k1Signature,
decodeSignature,
makeSecp256k1SignatureFromFixedLength,
} from "./signature";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export {
SigningCallback,
SigningCosmWasmClient,

View File

@ -1,8 +1,8 @@
import { Secp256k1, Sha256 } from "@iov/crypto";
import { Secp256k1, Secp256k1Signature, Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { Secp256k1Pen } from "./pen";
import { decodeSignature, makeSecp256k1SignatureFromFixedLength } from "./signature";
import { decodeSignature } from "./signature";
const { fromHex } = Encoding;
@ -37,7 +37,7 @@ describe("Sec256k1Pen", () => {
const { pubkey, signature } = decodeSignature(await pen.sign(data));
const valid = await Secp256k1.verifySignature(
makeSecp256k1SignatureFromFixedLength(signature),
Secp256k1Signature.fromFixedLength(signature),
new Sha256(data).digest(),
pubkey,
);

View File

@ -1,7 +1,7 @@
import { Secp256k1, Sha256 } from "@iov/crypto";
import { Secp256k1, Secp256k1Signature, Sha256 } from "@iov/crypto";
import { makeSignBytes } from "./encoding";
import { decodeSignature, makeSecp256k1SignatureFromFixedLength } from "./signature";
import { decodeSignature } from "./signature";
import { CosmosSdkTx } from "./types";
/**
@ -26,7 +26,7 @@ export async function findSequenceForSignedTx(
if (!firstSignature) throw new Error("Signature missing in tx");
const { pubkey, signature } = decodeSignature(firstSignature);
const secp256keSignature = makeSecp256k1SignatureFromFixedLength(signature);
const secp256keSignature = Secp256k1Signature.fromFixedLength(signature);
for (let s = min; s < upperBound; s++) {
// console.log(`Trying sequence ${s}`);

View File

@ -1,6 +1,4 @@
import { Secp256k1Signature } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import BN from "bn.js";
import { encodeSecp256k1Pubkey } from "./pubkey";
import { pubkeyType, StdSignature } from "./types";
@ -39,10 +37,3 @@ export function decodeSignature(
throw new Error("Unsupported pubkey type");
}
}
// TODO: use Secp256k1Signature.fromFixedLength once this is published https://github.com/iov-one/iov-core/pull/1401
export function makeSecp256k1SignatureFromFixedLength(signature: Uint8Array): Secp256k1Signature {
const unpaddedR = Uint8Array.from(new BN(signature.slice(0, 32)).toArray());
const unpaddedS = Uint8Array.from(new BN(signature.slice(32, 64)).toArray());
return new Secp256k1Signature(unpaddedR, unpaddedS);
}

View File

@ -23,11 +23,7 @@ export {
encodeSecp256k1Pubkey,
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export {
encodeSecp256k1Signature,
decodeSignature,
makeSecp256k1SignatureFromFixedLength,
} from "./signature";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export {
SigningCallback,
SigningCosmWasmClient,

View File

@ -1,4 +1,3 @@
import { Secp256k1Signature } from "@iov/crypto";
import { StdSignature } from "./types";
/**
* Takes a binary pubkey and signature to create a signature object
@ -13,4 +12,3 @@ export declare function decodeSignature(
readonly pubkey: Uint8Array;
readonly signature: Uint8Array;
};
export declare function makeSecp256k1SignatureFromFixedLength(signature: Uint8Array): Secp256k1Signature;

View File

@ -92,23 +92,23 @@
unique-filename "^1.1.1"
which "^1.3.1"
"@iov/bcp@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@iov/bcp/-/bcp-2.0.2.tgz#d63a996e0c2c7eff218f3dfca44dbcfaaf80ed0b"
integrity sha512-7uvDXh74CbU+xpIcLQDS0qNbvD1YDQXI+YlVMWMLQdnltAxGetKPA9vDI/rcl4rjYXkGbXWjXvFYBxftj5S5QQ==
"@iov/bcp@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@iov/bcp/-/bcp-2.1.0.tgz#d7c092a31e78dcdb80602e45f5fcb7c2f92e1417"
integrity sha512-FYpB8MX98aln7MFW6Pn1jA9uPVSYazigm5v5G3jM18aryusKroTindgRJvsRGhgr6VE5YIppohSfYNkA6WhLsg==
dependencies:
"@iov/crypto" "^2.0.2"
"@iov/encoding" "^2.0.2"
"@iov/crypto" "^2.1.0"
"@iov/encoding" "^2.1.0"
"@iov/stream" "^2.0.2"
type-tagger "^1.0.0"
xstream "^11.10.0"
"@iov/crypto@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@iov/crypto/-/crypto-2.0.2.tgz#22da5ca5c76e2f8e1a8e592195aa754584e1c1d6"
integrity sha512-UeBleADtU4RMPGjo5RmF+vAW0krV+TZtJetbY6i05J/cRWElKx/FxLvChRO4HciyE7KBKMTZmt+erKzpr/D9ZA==
"@iov/crypto@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@iov/crypto/-/crypto-2.1.0.tgz#10e91b6692e154958c11626dfd096a80e8a481a4"
integrity sha512-jnb4XuK50admolm7fBxOcxfAW2TO+wYrZlhDWiMETItY/Y5gNNa1zaDSO2wNIjjfGng+8nQ1yqnNhqy7busV2Q==
dependencies:
"@iov/encoding" "^2.0.2"
"@iov/encoding" "^2.1.0"
bip39 "^3.0.2"
bn.js "^4.11.8"
elliptic "^6.4.0"
@ -120,24 +120,24 @@
type-tagger "^1.0.0"
unorm "^1.5.0"
"@iov/encoding@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@iov/encoding/-/encoding-2.0.2.tgz#e83330aa8dcf0de422a1599a6d08653f74275f8e"
integrity sha512-IlqBGZz4iOz6QjYJB0rCVCiaZojOJpSjapT8575M8BZ7K40jLVe1DaSxGFF0G8orY9I9Kc/7fGMvr0a2wR3HAw==
"@iov/encoding@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@iov/encoding/-/encoding-2.1.0.tgz#434203c39874c68bc1d96e1278251f0feb23be07"
integrity sha512-5IOdLO7Xg/uRykuiCqeMYghQ3IjWDtGxv7NTWXkgpHuna0aewx43mRpT2NPCpOZd1tpuorDtQ7/zbDNRaIIF/w==
dependencies:
base64-js "^1.3.0"
bech32 "^1.1.3"
bn.js "^4.11.8"
readonly-date "^1.0.0"
"@iov/keycontrol@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@iov/keycontrol/-/keycontrol-2.0.2.tgz#10113d5d8223912f6325f1fc68746852fd1dec23"
integrity sha512-XubfYpNFr/xwGQC7e0VFc9oug4S5/muzIgQJRDxGcGNyE1YhQbfAzYLfxC7Th0Dq5rRui3MKWhLehYydqNxvvw==
"@iov/keycontrol@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@iov/keycontrol/-/keycontrol-2.1.0.tgz#ba67337a9b50e68fcca2bd54563602d7667c6f76"
integrity sha512-mZm0ENishX5ho8w6yL7MQN7tQOphptCgOodH0YUNwtOeNjSgczjYuOoKvcjWVsn+KGNOV7qDoRWRsxUWV50jtw==
dependencies:
"@iov/bcp" "^2.0.2"
"@iov/crypto" "^2.0.2"
"@iov/encoding" "^2.0.2"
"@iov/bcp" "^2.1.0"
"@iov/crypto" "^2.1.0"
"@iov/encoding" "^2.1.0"
"@iov/stream" "^2.0.2"
"@types/abstract-leveldown" "^5.0.1"
"@types/levelup" "^3.1.0"