Rewrite yarn.lock (#580)
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# 2.8.0-beta.x
|
||||
|
||||
- Keypair will now throw an error when attempting to sign/derive using a locked pair (Thanks to https://github.com/h4x3rotab)
|
||||
|
||||
# 2.7.1 Mar 31, 2020
|
||||
|
||||
- Add `bnSqrt` to calculate the integer sqrt via Newton iteration
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@polkadot/dev": "^0.52.3",
|
||||
"@polkadot/dev": "^0.52.4",
|
||||
"@polkadot/ts": "^0.3.14",
|
||||
"@types/jest": "^25.1.4"
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ describe('pair', (): void => {
|
||||
const encoded = keyring.alice.encodePkcs8(PASS);
|
||||
|
||||
const pair = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.alice.publicKey });
|
||||
|
||||
pair.decodePkcs8(PASS, encoded);
|
||||
|
||||
expect(pair.isLocked).toEqual(false);
|
||||
@@ -96,6 +97,7 @@ describe('pair', (): void => {
|
||||
|
||||
it('fails to sign when locked', (): void => {
|
||||
const pair = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.alice.publicKey });
|
||||
|
||||
expect(pair.isLocked).toEqual(true);
|
||||
expect((): Uint8Array =>
|
||||
pair.sign(new Uint8Array([0]))
|
||||
|
||||
@@ -147,6 +147,7 @@ export default function createPair ({ toSS58, type }: Setup, { publicKey, secret
|
||||
},
|
||||
sign: (message: Uint8Array, options?: SignOptions): Uint8Array => {
|
||||
assert(!isLocked(secretKey), 'Cannot sign with a locked key pair');
|
||||
|
||||
return sign(type, message, { publicKey, secretKey }, options);
|
||||
},
|
||||
toJson: (passphrase?: string): KeyringPair$Json =>
|
||||
|
||||
@@ -13,8 +13,8 @@ describe('naclOpen', (): void => {
|
||||
const receiver = naclKeypairFromString('receiver');
|
||||
const senderBox = naclBoxKeypairFromSecret(sender.secretKey);
|
||||
const receiverBox = naclBoxKeypairFromSecret(receiver.secretKey);
|
||||
|
||||
const { nonce, sealed } = naclSeal(message, senderBox.secretKey, receiverBox.publicKey);
|
||||
|
||||
expect(
|
||||
naclOpen(sealed, nonce, senderBox.publicKey, receiverBox.secretKey)
|
||||
).toEqual(
|
||||
@@ -32,16 +32,19 @@ describe('naclOpen', (): void => {
|
||||
|
||||
// Receiver sends encrypting public key to receive message to decrypt with his private key
|
||||
const receiverIdBoxKey = naclBoxKeypairFromSecret(receiverIdKey.secretKey);
|
||||
|
||||
console.log(`Receiver sends receiver's public key to sender ${receiverIdBoxKey.publicKey}`);
|
||||
|
||||
// Sender encrypts message to send with the public key the receiver sent and send it to receiver
|
||||
const senderIdBoxKey = naclBoxKeypairFromSecret(senderIdKey.secretKey);
|
||||
const message = new Uint8Array([1, 2, 3, 4, 5, 4, 3, 2, 1]);
|
||||
const { nonce, sealed } = naclSeal(message, senderIdBoxKey.secretKey, receiverIdBoxKey.publicKey);
|
||||
|
||||
console.log(`Sender sends encrypted message to receiver ${sealed}, ${nonce}`);
|
||||
|
||||
// Receiver opens encrypted message from the sender
|
||||
let opened = naclOpen(sealed, nonce, senderIdBoxKey.publicKey, receiverIdBoxKey.secretKey);
|
||||
|
||||
console.log(`The sealed message is ${opened}`);
|
||||
|
||||
// Oh no the Id key is hacked, derive Id key again from another index
|
||||
@@ -50,6 +53,7 @@ describe('naclOpen', (): void => {
|
||||
|
||||
// Receiver sends encrypting public key to receive message to decrypt with his private key
|
||||
const receiverIdBoxKey2 = naclBoxKeypairFromSecret(receiverIdKey2.secretKey);
|
||||
|
||||
console.log(`Receiver sends receiver's public key to sender ${receiverIdBoxKey2.publicKey}`);
|
||||
|
||||
// Sender encrypts message to send with the public key the receiver sent and send it to receiver
|
||||
@@ -58,6 +62,7 @@ describe('naclOpen', (): void => {
|
||||
let ctx = naclSeal(message2, senderIdBoxKey2.secretKey, receiverIdBoxKey2.publicKey);
|
||||
const sealed2 = ctx.sealed;
|
||||
const nonce2 = ctx.nonce;
|
||||
|
||||
console.log(`Sender sends encrypted message to receiver ${sealed}, ${nonce}`);
|
||||
|
||||
// Receiver opens encrypted message from the sender
|
||||
@@ -67,14 +72,18 @@ describe('naclOpen', (): void => {
|
||||
// This time derive key for each message to send and receive
|
||||
// Receiver sends encrypting public key to receive message to decrypt with his private key
|
||||
const receiverIdBoxKey2One = naclBoxKeypairFromSecret(receiverIdBoxKey2.secretKey);
|
||||
|
||||
console.log(`Receiver sends receiver's public key to sender ${receiverIdBoxKey2One.publicKey}`);
|
||||
|
||||
// Sender encrypts message to send with the public key the receiver sent and send it to receiver
|
||||
const senderIdBoxKey2One = naclBoxKeypairFromSecret(senderIdBoxKey2.secretKey);
|
||||
const message3 = new Uint8Array([1, 2, 3, 4, 5, 4, 3, 2, 1]);
|
||||
|
||||
ctx = naclSeal(message3, senderIdBoxKey2One.secretKey, receiverIdBoxKey2One.publicKey);
|
||||
|
||||
const sealed3 = ctx.sealed;
|
||||
const nonce3 = ctx.nonce;
|
||||
|
||||
console.log(`Sender sends encrypted message to receiver ${sealed3}, ${nonce3}`);
|
||||
|
||||
// Receiver opens encrypted message from the sender
|
||||
|
||||
@@ -13,6 +13,7 @@ describe('naclSeal', (): void => {
|
||||
const receiverBox = naclBoxKeypairFromSecret(receiver.secretKey);
|
||||
const senderBoxSecret = senderBox.secretKey;
|
||||
const receiverBoxPublic = receiverBox.publicKey;
|
||||
|
||||
expect(
|
||||
naclSeal(message, senderBoxSecret, receiverBoxPublic, new Uint8Array(24))
|
||||
).toEqual({
|
||||
|
||||
@@ -45,6 +45,7 @@ describe('formatBalance', (): void => {
|
||||
toBn: (): BN => TESTVAL,
|
||||
unwrap: (): BN => TESTVAL
|
||||
};
|
||||
|
||||
expect(
|
||||
formatBalance(compact, { decimals: 15, withSi: true })
|
||||
).toEqual('123.456µ Unit');
|
||||
|
||||
Reference in New Issue
Block a user