Drop sr25519 verify_simple_preaudit_deprecated (#54)
* Drop sr25519 verify_simple_preaudit_deprecated * Add missing Signature import * Update test-verctor, 0.8.5+ only signatures * Trigger * Pin Rust nightly * Pin via run * De-dup nightlies * Update tests to use nightly-2020-02-17 * Update CHANGELOG * Typo
This commit is contained in:
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
${{ runner.os }}-yarn-
|
||||
- name: test
|
||||
run: |
|
||||
rustup toolchain install nightly
|
||||
rustup toolchain install nightly-2020-02-17
|
||||
yarn install --frozen-lockfile
|
||||
yarn test
|
||||
|
||||
@@ -81,6 +81,6 @@ jobs:
|
||||
${{ runner.os }}-yarn-
|
||||
- name: build
|
||||
run: |
|
||||
rustup toolchain install nightly
|
||||
rustup toolchain install nightly-2020-02-17
|
||||
yarn install --frozen-lockfile
|
||||
yarn build
|
||||
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
rustup toolchain install nightly
|
||||
rustup toolchain install nightly-2020-02-17
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-ci-ghact-build
|
||||
|
||||
|
||||
+7
-1
@@ -1,4 +1,10 @@
|
||||
# 1.0.1 Feb 15, 2020
|
||||
# 1.1.0-beta.x
|
||||
|
||||
- **Important** The sr25519 interface dropped the use of `verify_simple_preaudit_deprecated` for signature verification, instead it now uses `verify_simple`. Only schnorrkel 0.8+ signatures will now pass verification. This is a follow-up of the 0.1 signing support that was dropped in a previous version.
|
||||
- Update all test vectors to only cater for schnorrkel 0.8+ era signatures based on the above change
|
||||
- Pin Rust nightly to last-known-working nightly-2020-02-17 on CI (compiler issues, should to be reverted in a future release)
|
||||
|
||||
# 1.0.1 Feb 15, 2020
|
||||
|
||||
- No functionality changes from 0.20.1. The interfaces here are stable in the current iteration.
|
||||
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.7.5"
|
||||
"typescript": "^3.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "./scripts/build.sh",
|
||||
@@ -20,8 +20,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.3",
|
||||
"@polkadot/dev": "^0.40.16",
|
||||
"@polkadot/util": "^2.3.0-beta.6",
|
||||
"@polkadot/dev": "^0.41.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"override-require": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// forked at commit eff430ddc3090f56317c80654208b8298ef7ab3f
|
||||
|
||||
use schnorrkel::{
|
||||
ExpansionMode, Keypair, MiniSecretKey, PublicKey, SecretKey,
|
||||
ExpansionMode, Keypair, MiniSecretKey, PublicKey, SecretKey, Signature,
|
||||
derive::{Derivation, ChainCode, CHAIN_CODE_LENGTH},
|
||||
};
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -126,19 +126,12 @@ pub fn ext_sr_sign(public: &[u8], secret: &[u8], message: &[u8]) -> Vec<u8> {
|
||||
/// * pubkey: UIntArray with 32 element
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_sr_verify(signature: &[u8], message: &[u8], public: &[u8]) -> bool {
|
||||
// This is where we only verify 0.8.0+ signatures, replacing the code below
|
||||
//
|
||||
// match Signature::from_bytes(signature) {
|
||||
// Ok(signature) => PublicKey::from_bytes(public).unwrap()
|
||||
// .verify_simple(SIGNING_CTX, message, &signature)
|
||||
// .is_ok(),
|
||||
// Err(_) => false
|
||||
// };
|
||||
|
||||
PublicKey::from_bytes(public)
|
||||
.unwrap()
|
||||
.verify_simple_preaudit_deprecated(SIGNING_CTX, message, &signature)
|
||||
.is_ok()
|
||||
match Signature::from_bytes(signature) {
|
||||
Ok(signature) => PublicKey::from_bytes(public).unwrap()
|
||||
.verify_simple(SIGNING_CTX, message, &signature)
|
||||
.is_ok(),
|
||||
Err(_) => false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -209,9 +202,9 @@ pub mod tests {
|
||||
|
||||
#[test]
|
||||
fn can_verify_known_message() {
|
||||
let message = b"Verifying that I am the owner of 5G9hQLdsKQswNPgB499DeA5PkFBbgkLPJWkkS6FAM6xGQ8xD. Hash: 221455a3\n";
|
||||
let public = hex!("b4bfa1f7a5166695eb75299fd1c4c03ea212871c342f2c5dfea0902b2c246918");
|
||||
let signature = hex!("5a9755f069939f45d96aaf125cf5ce7ba1db998686f87f2fb3cbdea922078741a73891ba265f70c31436e18a9acd14d189d73c12317ab6c313285cd938453202");
|
||||
let message = b"I hereby verify that I control 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
|
||||
let public = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d");
|
||||
let signature = hex!("1037eb7e51613d0dcf5930ae518819c87d655056605764840d9280984e1b7063c4566b55bf292fcab07b369d01095879b50517beca4d26e6a65866e25fec0d83");
|
||||
let is_valid = ext_sr_verify(&signature, message, &public);
|
||||
|
||||
assert!(is_valid);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Copyright 2019-2020 @polkadot/wasm-crypto authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
|
||||
const crypto = require('crypto');
|
||||
@@ -35,9 +35,9 @@ function sr25519_devFromSeed (wasm) {
|
||||
}
|
||||
|
||||
function sr25519_verifyExisting (wasm) {
|
||||
const PK = hexToU8a('0xb4bfa1f7a5166695eb75299fd1c4c03ea212871c342f2c5dfea0902b2c246918');
|
||||
const MESSAGE = stringToU8a('Verifying that I am the owner of 5G9hQLdsKQswNPgB499DeA5PkFBbgkLPJWkkS6FAM6xGQ8xD. Hash: 221455a3\n');
|
||||
const SIGNATURE = hexToU8a('0x5a9755f069939f45d96aaf125cf5ce7ba1db998686f87f2fb3cbdea922078741a73891ba265f70c31436e18a9acd14d189d73c12317ab6c313285cd938453202');
|
||||
const PK = hexToU8a('0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d');
|
||||
const MESSAGE = stringToU8a('I hereby verify that I control 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
const SIGNATURE = hexToU8a('0xb83881d3bd7302981ee1c504fe5b7b394682927131fc0846fd616bb40fa14d02640fd2aca785b4cb57904765c2e4e75f59a7dd30154c209964369912091f6981');
|
||||
|
||||
const isValid = wasm.sr25519Verify(SIGNATURE, MESSAGE, PK);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ rm -rf ./build ./pkg
|
||||
|
||||
# build new via nightly & wasm-pack
|
||||
echo "*** Building WASM output"
|
||||
rustup run nightly wasm-pack build --release --scope polkadot --target nodejs
|
||||
rustup run nightly-2020-02-17 wasm-pack build --release --scope polkadot --target nodejs
|
||||
mv pkg build
|
||||
|
||||
# optimise
|
||||
|
||||
@@ -16,7 +16,7 @@ for PKG in "${PACKAGES[@]}"; do
|
||||
cd $PKG
|
||||
|
||||
echo "*** Testing Rust"
|
||||
RUST_BACKTRACE=full rustup run nightly cargo test --release -- --nocapture
|
||||
RUST_BACKTRACE=full rustup run nightly-2020-02-17 cargo test --release -- --nocapture
|
||||
|
||||
cd ..
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user