@rsksmart/rif-communications-pubsub
Version:
396 lines (374 loc) • 13.3 kB
Plain Text
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
/*!
* aead.js - aead for bcrypto
* Copyright (c) 2016-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources:
* https://tools.ietf.org/html/rfc7539#section-2.8
* https://github.com/openssh/openssh-portable
*/
/*!
* assert.js - assert for bcrypto
* Copyright (c) 2020, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* bn.js - big numbers for bcrypto
* Copyright (c) 2017-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* bn.js - big numbers for bcrypto
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Parts of this software are based on indutny/bn.js:
* Copyright (c) 2015, Fedor Indutny (MIT License).
* https://github.com/indutny/bn.js
*
* Parts of this software are based on golang/go:
* Copyright (c) 2009, The Go Authors. All rights reserved.
* https://github.com/golang/go
*
* Parts of this software are based on openssl/openssl:
* Copyright (c) 1998-2018, The OpenSSL Project (Apache License v2.0).
* Copyright (c) 1995-1998, Eric A. Young, Tim J. Hudson. All rights reserved.
* https://github.com/openssl/openssl
*
* Parts of this software are based on libgmp:
* Copyright (c) 1991-1997, 1999-2014, Free Software Foundation, Inc.
* https://gmplib.org/
*
* Parts of this software are based on v8/v8:
* Copyright (c) 2017, The V8 Project Authors (BSD-Style License).
* https://github.com/v8/v8
*
* Resources:
* https://github.com/indutny/bn.js/blob/master/lib/bn.js
* https://github.com/indutny/miller-rabin/blob/master/lib/mr.js
* https://github.com/golang/go/blob/master/src/math/big/int.go
* https://github.com/golang/go/blob/master/src/math/big/nat.go
* https://github.com/golang/go/blob/master/src/math/big/prime.go
* https://github.com/openssl/openssl/tree/master/crypto/bn
* https://github.com/openssl/openssl/blob/master/crypto/bn/bn_kron.c
* https://github.com/gnutls/nettle/blob/master/mini-gmp.c
* https://github.com/v8/v8/blob/master/src/objects/bigint.cc
*/
/*!
* chacha20.js - chacha20 for bcrypto
* Copyright (c) 2016-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources
* https://en.wikipedia.org/wiki/Chacha20
* https://tools.ietf.org/html/rfc7539#section-2
* https://cr.yp.to/chacha.html
*/
/*!
* custom.js - custom inspect symbol for bcrypto
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* ecdh.js - ECDH for bcrypto
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources:
* https://cr.yp.to/ecdh.html
* https://cr.yp.to/ecdh/curve25519-20060209.pdf
* https://tools.ietf.org/html/rfc7748
*/
/*!
* elliptic.js - elliptic curves for bcrypto
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Parts of this software are based on indutny/elliptic:
* Copyright (c) 2014, Fedor Indutny (MIT License).
* https://github.com/indutny/elliptic
*
* Formulas from DJB and Tanja Lange [EFD].
*
* References:
*
* [GECC] Guide to Elliptic Curve Cryptography
* D. Hankerson, A. Menezes, and S. Vanstone
* https://tinyurl.com/guide-to-ecc
*
* [GLV] Faster Point Multiplication on Elliptic Curves
* R. Gallant, R. Lambert, and S. Vanstone
* https://link.springer.com/content/pdf/10.1007/3-540-44647-8_11.pdf
*
* [MONT1] Montgomery curves and the Montgomery ladder
* Daniel J. Bernstein, Tanja Lange
* https://eprint.iacr.org/2017/293.pdf
*
* [COZ] Scalar Multiplication on Elliptic Curves from Co-Z Arithmetic
* R. Goundar, M. Joye, A. Miyaji, M. Rivain, A. Venelli
* https://www.matthieurivain.com/files/jcen11b.pdf
*
* [SQUARED] Elligator Squared
* Mehdi Tibouchi
* https://eprint.iacr.org/2014/043.pdf
*
* [SEC1] SEC 1 - Standards for Efficient Cryptography Group
* Certicom Research
* https://www.secg.org/sec1-v2.pdf
*
* [SEC2] SEC 2: Recommended Elliptic Curve Domain Parameters
* Certicom Research
* https://www.secg.org/sec2-v2.pdf
*
* [SIDE1] Elliptic Curves and Side-Channel Attacks
* Marc Joye
* https://pdfs.semanticscholar.org/8d69/9645033e25d74fcfd4cbf07a770d2e943e14.pdf
*
* [BLIND] Side-Channel Analysis on Blinding Regular Scalar Multiplications
* B. Feix, M. Roussellet, A. Venelli
* https://eprint.iacr.org/2014/191.pdf
*
* [ALT] Alternative Elliptic Curve Representations
* R. Struik
* https://tools.ietf.org/id/draft-ietf-lwig-curve-representations-02.html
*
* [ARITH1] Arithmetic of Elliptic Curves
* Christophe Doche, Tanja Lange
* Handbook of Elliptic and Hyperelliptic Curve Cryptography
* Page 267, Section 13 (978-1-58488-518-4)
* https://hyperelliptic.org/HEHCC/index.html
*
* [ARITH2] The Arithmetic of Elliptic Curves, 2nd Edition
* Joseph H. Silverman
* http://www.pdmi.ras.ru/~lowdimma/BSD/Silverman-Arithmetic_of_EC.pdf
*
* [EFD] Explicit-Formulas Database
* Daniel J. Bernstein, Tanja Lange
* https://hyperelliptic.org/EFD/index.html
*
* [SAFE] SafeCurves: choosing safe curves for elliptic-curve cryptography
* Daniel J. Bernstein
* https://safecurves.cr.yp.to/
*
* [4GLV] Refinement of the Four-Dimensional GLV Method on Elliptic Curves
* Hairong Yi, Yuqing Zhu, and Dongdai Lin
* http://www.site.uottawa.ca/~cadams/papers/prepro/paper_19_slides.pdf
*
* [ICART] How to Hash into Elliptic Curves
* Thomas Icart
* https://eprint.iacr.org/2009/226.pdf
*
* [SSWU1] Efficient Indifferentiable Hashing into Ordinary Elliptic Curves
* E. Brier, J. Coron, T. Icart, D. Madore, H. Randriam, M. Tibouchi
* https://eprint.iacr.org/2009/340.pdf
*
* [SSWU2] Rational points on certain hyperelliptic curves over finite fields
* Maciej Ulas
* https://arxiv.org/abs/0706.1448
*
* [H2EC] Hashing to Elliptic Curves
* A. Faz-Hernandez, S. Scott, N. Sullivan, R. S. Wahby, C. A. Wood
* https://git.io/JeWz6
* https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve
*
* [SVDW1] Construction of Rational Points on Elliptic Curves
* A. Shallue, C. E. van de Woestijne
* https://works.bepress.com/andrew_shallue/1/download/
*
* [SVDW2] Indifferentiable Hashing to Barreto-Naehrig Curves
* Pierre-Alain Fouque, Mehdi Tibouchi
* https://www.di.ens.fr/~fouque/pub/latincrypt12.pdf
*
* [SVDW3] Covert ECDH over secp256k1
* Pieter Wuille
* https://gist.github.com/sipa/29118d3fcfac69f9930d57433316c039
*
* [MONT2] Montgomery Curve (wikipedia)
* https://en.wikipedia.org/wiki/Montgomery_curve
*
* [SIDE2] Weierstrass Elliptic Curves and Side-Channel Attacks
* Eric Brier, Marc Joye
* http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.2.273&rep=rep1&type=pdf
*
* [SIDE3] Unified Point Addition Formulae and Side-Channel Attacks
* Douglas Stebila, Nicolas Theriault
* https://eprint.iacr.org/2005/419.pdf
*
* [MONT3] Montgomery Curves and their arithmetic
* C. Costello, B. Smith
* https://eprint.iacr.org/2017/212.pdf
*
* [ELL2] Elliptic-curve points indistinguishable from uniform random strings
* D. Bernstein, M. Hamburg, A. Krasnova, T. Lange
* https://elligator.cr.yp.to/elligator-20130828.pdf
*
* [RFC7748] Elliptic Curves for Security
* A. Langley, M. Hamburg, S. Turner
* https://tools.ietf.org/html/rfc7748
*
* [TWISTED] Twisted Edwards Curves
* D. Bernstein, P. Birkner, M. Joye, T. Lange, C. Peters
* https://eprint.iacr.org/2008/013.pdf
*
* [ELL1] Injective Encodings to Elliptic Curves
* P. Fouque, A. Joux, M. Tibouchi
* https://eprint.iacr.org/2013/373.pdf
*
* [ISOGENY] Twisting Edwards curves with isogenies
* Mike Hamburg
* https://www.shiftleft.org/papers/isogeny/isogeny.pdf
*
* [RFC8032] Edwards-Curve Digital Signature Algorithm (EdDSA)
* S. Josefsson, SJD AB, I. Liusvaara
* https://tools.ietf.org/html/rfc8032
*
* [TIMING] Remote Timing Attacks are Still Practical
* B. Brumley, N. Tuveri
* https://eprint.iacr.org/2011/232.pdf
*
* [SCHNORR] Schnorr Signatures for secp256k1
* Pieter Wuille
* https://github.com/sipa/bips/blob/d194620/bip-schnorr.mediawiki
*
* [BIP340] Schnorr Signatures for secp256k1
* Pieter Wuille, Jonas Nick, Tim Ruffing
* https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
*
* [JCEN12] Efficient Software Implementation of Public-Key Cryptography
* on Sensor Networks Using the MSP430X Microcontroller
* C. P. L. Gouvea, L. B. Oliveira, J. Lopez
* http://conradoplg.cryptoland.net/files/2010/12/jcen12.pdf
*
* [FIPS186] Federal Information Processing Standards Publication
* National Institute of Standards and Technology
* https://tinyurl.com/fips-186-3
*
* [RFC5639] Elliptic Curve Cryptography (ECC) Brainpool
* Standard Curves and Curve Generation
* M. Lochter, BSI, J. Merkle
* https://tools.ietf.org/html/rfc5639
*
* [TWISTEQ] Twisted Edwards & Short Weierstrass Equivalence
* Christopher Jeffrey
* https://gist.github.com/chjj/16ba7fa08d64e8dda269a9fe5b2a8bbc
*
* [ECPM] Elliptic Curve Point Multiplication (wikipedia)
* https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication
*/
/*!
* hkdf.js - hkdf for bcrypto
* Copyright (c) 2014-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources:
* https://en.wikipedia.org/wiki/HKDF
* https://tools.ietf.org/html/rfc5869
*/
/*!
* hkdf.js - hkdf for bcrypto
* Copyright (c) 2017-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* hmac.js - hmac for bcrypto
* Copyright (c) 2016-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Parts of this software are based on indutny/hash.js:
* Copyright (c) 2014, Fedor Indutny (MIT License).
* https://github.com/indutny/hash.js
*
* Resources:
* https://en.wikipedia.org/wiki/HMAC
* https://tools.ietf.org/html/rfc2104
* https://github.com/indutny/hash.js/blob/master/lib/hash/hmac.js
*/
/*!
* poly1305.js - poly1305 for bcrypto
* Copyright (c) 2016-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Parts of this software are based on floodyberry/poly1305-donna:
* Placed into the public domain by Andrew Moon.
* https://github.com/floodyberry/poly1305-donna
*
* Resources:
* https://en.wikipedia.org/wiki/Poly1305
* https://cr.yp.to/mac.html
* https://tools.ietf.org/html/rfc7539#section-2.5
* https://github.com/floodyberry/poly1305-donna/blob/master/poly1305-donna-16.h
*/
/*!
* random.js - random for bcrypto
* Copyright (c) 2017-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* random.js - random number generator for bcrypto
* Copyright (c) 2014-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources:
* https://wiki.openssl.org/index.php/Random_Numbers
* https://csrc.nist.gov/projects/random-bit-generation/
* http://www.pcg-random.org/posts/bounded-rands.html
* https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
*/
/*!
* sha256.js - SHA256 implementation for bcrypto
* Copyright (c) 2016-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Parts of this software are based on indutny/hash.js:
* Copyright (c) 2014, Fedor Indutny (MIT License).
* https://github.com/indutny/hash.js
*
* Resources:
* https://en.wikipedia.org/wiki/SHA-2
* https://tools.ietf.org/html/rfc4634
* https://github.com/indutny/hash.js/blob/master/lib/hash/sha/256.js
*/
/*!
* util.js - encoding utils for javascript
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
/*!
* x25519.js - x25519 for bcrypto
* Copyright (c) 2018-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*
* Resources:
* https://en.wikipedia.org/wiki/Curve25519
* https://cr.yp.to/ecdh/curve25519-20060209.pdf
* https://tools.ietf.org/html/rfc7748#section-5
*/
/*! https://mths.be/punycode v1.4.1 by @mathias */
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/