EOSIO / eosjs-ecc

Elliptic curve cryptography functions: Private Key, Public Key, Signature, AES, Encryption, Decryption
287 stars 119 forks source link

Can the toPublic method add an pubkey_prefix parameter for user-defined use? #57

Open cppfuns opened 5 years ago

cppfuns commented 5 years ago

https://github.com/EOSIO/eosjs-ecc/blob/2063257e8d02e82ce4ca1d0fdadf451281b33d1e/src/key_private.js#L62

Original edition

function toPublic() {
        if (public_key) {
            // cache
            // S L O W in the browser
            return public_key
        }
        const Q = secp256k1.G.multiply(d);
        return public_key = PublicKey.fromPoint(Q);
    }

Revised

function toPublic(pubkey_prefix = 'EOS') {
        if (public_key) {
            // cache
            // S L O W in the browser
            return public_key
        }
        const Q = secp256k1.G.multiply(d);
        return public_key = PublicKey.fromPoint(Q, pubkey_prefix );
    }

https://www.bcskill.com/index.php/archives/700.html