How to use the ec function from elliptic

Find comprehensive JavaScript elliptic.ec code examples handpicked from public code repositorys.

elliptic.ec is a module in JavaScript which provides an implementation of Elliptic Curve Cryptography (ECC) operations using the secp256k1 curve, such as key generation, signing and verification.

13
14
15
16
17
18
19
20
21
22
23
24
25


const aesKey = require('./aes/pkcs11_key.js');
const ecdsaKey = require('./ecdsa/pkcs11_key.js');


const elliptic = require('elliptic');
const EC = elliptic.ec;


const jsrsa = require('jsrsasign');
const KEYUTIL = jsrsa.KEYUTIL;

fork icon525
star icon769
watch icon63

+ 19 other calls in file

3
4
5
6
7
8
9
10
11
12
const assert = require("assert")
const brorand = require("brorand")
const BN = require("bn.js")
const elliptic = require("elliptic");
const Ed25519 = elliptic.eddsa('ed25519');
const Secp256k1 = elliptic.ec('secp256k1');
const hashjs = require("hash.js");
const Sha512 = require("ripple-keypairs/dist/Sha512")
const { codec, encodeAccountPublic, encodeNodePublic } = require("ripple-address-codec");

fork icon973
star icon414
watch icon136

How does elliptic.ec work?

elliptic.ec is a constructor function in the elliptic library that creates an instance of an elliptic curve, which is a mathematical construct used for public key cryptography. The ec instance can be used to generate key pairs, sign messages, and verify signatures using the elliptic curve algorithm. The elliptic curve algorithm involves manipulating points on an elliptic curve to generate and verify cryptographic keys and signatures.

4
5
6
7
8
9
10
11
12
 */
import { publicKeyCreate, publicKeyConvert } from 'secp256k1'
import * as BlocksoftRandom from 'react-native-blocksoft-random'

const elliptic = require('elliptic')
const ec = new elliptic.ec('secp256k1')

const createHash = require('create-hash')
const createHmac = require('create-hmac')
fork icon80
star icon111
watch icon12

+ 3 other calls in file

0
1
2
3
4
5
6
7
8
9
'use strict'

const assert = require('./signatures/assert')
const ee = require('events').EventEmitter
const elliptic = require('elliptic')
const curve = elliptic.ec('secp256k1').curve
const crypto = require('crypto')
const Signature = require('elliptic/lib/elliptic/ec/signature')
const BN = require('bn.js')
const secp256k1 = require('secp256k1')
fork icon22
star icon45
watch icon26

+ 9 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
const elliptic = require("elliptic");
const ec = new elliptic.ec("secp256k1");

// Generate a new key pair
const keyPair = ec.genKeyPair();

// Get the private and public key
const privateKey = keyPair.getPrivate().toString(16);
const publicKey = keyPair.getPublic().encode("hex");

In this example, the elliptic module is first required and an instance of elliptic.ec is created with the secp256k1 curve. Then, a new key pair is generated using the genKeyPair method. Finally, the private and public keys are extracted using the getPrivate and getPublic methods respectively, and converted to hex format using the toString and encode methods.

29
30
31
32
33
34
35
36
37
38
const secureRandom = require('secure-random');
const elliptic = require('elliptic');
const ripemd160 = require('ripemd160');
const base58 = require('bs58');
const BigInteger = require("bigi");
const ec = new elliptic.ec('secp256k1');

const CHECKSUM_LENGTH = 4; // 4 bytes
/**
 * Generate & Initialize Wallet Class
fork icon6
star icon2
watch icon2

+ 5 other calls in file

31
32
33
34
35
36
37
38
39
40
/**
 * elliptic.js secp256k1 curve.
 * @type {Object}
 */

ec.elliptic = elliptic.ec('secp256k1');

/**
 * elliptic.js signature constructor.
 * @static
fork icon839
star icon0
watch icon3

+ 13 other calls in file

17
18
19
20
21
22
23
24
25
26
...

```javascript
let elliptic = require('elliptic');
let sha3 = require('js-sha3');
let ec = new elliptic.ec('secp256k1');

// let keyPair = ec.genKeyPair(); // Generate random keys
let keyPair = ec.keyFromPrivate(
 "97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a");
fork icon359
star icon0
watch icon127

2
3
4
5
6
7
8
9
10
11
import { rippleEpocheTimeToUTC } from '../../utils/normalizers';
import { createHash } from 'crypto';

const elliptic = require('elliptic');
const ed25519 = new elliptic.eddsa('ed25519')
const secp256k1 = new elliptic.ec('secp256k1')

const codec =
{
    address: require('ripple-address-codec')
fork icon1
star icon12
watch icon2

120
121
122
123
124
125
126
127
128
129
130
131


  return SECP256K1Client;
}();


SECP256K1Client.algorithmName = 'ES256K';
SECP256K1Client.ec = new _elliptic.ec('secp256k1');
SECP256K1Client.keyEncoder = new _reactNativeKeyEncoder2.default({
  curveParameters: [1, 3, 132, 0, 10],
  privatePEMOptions: { label: 'EC PRIVATE KEY' },
  publicPEMOptions: { label: 'PUBLIC KEY' },
fork icon1
star icon3
watch icon2

38
39
40
41
42
43
44
45
46
47
48
var utils = require("web3-utils");
var helpers = require("web3-core-helpers");
var Transaction = require("ethereumjs-tx").Transaction;
var Common = require("ethereumjs-common").default;
const elliptic = require("elliptic");
const secp256k1 = new elliptic.ec("secp256k1"); // eslint-disable-line


var isNot = function (value) {
    return _.isUndefined(value) || _.isNull(value);
};
fork icon0
star icon0
watch icon5

+ 33 other calls in file

19
20
21
22
23
24
25
26
27
28
29
30
31
const { send  } = "@onflow/transport-http"


const { SHA3 } = require('sha3');
const elliptic = require('elliptic');


const curve = new elliptic.ec("p256");


 
config({
   "accessNode.api": process.env.AccessNode_Api, // Mainnet: "https://rest-mainnet.onflow.org"
fork icon0
star icon0
watch icon1

+ 2 other calls in file

18
19
20
21
22
23
24
25
26
27
28
29
30
var api = require('../../api.js');
var jsrsa = require('jsrsasign');
var asn1 = jsrsa.asn1;


var elliptic = require('elliptic');
var EC = elliptic.ec;




/**
 * This module implements the {@link module:api.Key} interface, for ECDSA key management
fork icon0
star icon0
watch icon1

24
25
26
27
28
29
30
31
32
33
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowService = void 0;
const fcl = __importStar(require("@onflow/fcl"));
const elliptic_1 = require("elliptic");
const sha3_1 = require("sha3");
const ec = new elliptic_1.ec("p256");
class FlowService {
    constructor(minterFlowAddress, minterPrivateKeyHex, minterAccountIndex) {
        this.minterFlowAddress = minterFlowAddress;
        this.minterPrivateKeyHex = minterPrivateKeyHex;
fork icon0
star icon0
watch icon1