bitchan / eccrypto Goto Github PK
View Code? Open in Web Editor NEWJavaScript Elliptic curve cryptography library
License: Creative Commons Zero v1.0 Universal
JavaScript Elliptic curve cryptography library
License: Creative Commons Zero v1.0 Universal
calling browser.aesCbcEncrypt (
encryption_key = 916819a3e7f2a3f16a6fc12dc0515acb1e2570687a7968c9cb0bef7025623ee0
iv = 8d0e8b2db03c966dccb4ca2bfbb31d6f
message = 6c393a46494e445f4e4f44456c33323ac6a3da79d9af73fa972d4e62effa62bc927c651c602ddd658637c1402f5a2bde6565
)
the ciphertext output is fe99edc46b894035d1b719ab672fe2d7.
Shouldn't the final output had to have the same length as my initial message?
Also, I can't decrypt it on my node.js.
Shouldn't the ciphertext be:
8c 76 30 c2 0d 39 9e 5e e6 2f 1f bc 13 94 90 4b 98 0c d7 24 32 fa c7 ba 01 19 09 8c f6 a4 83 97 33 31 14 ae ee f5 01 50 24 10 5b e5 f3 54 10 61 33 31 14 ae ee f5 01 50 24 10 5b e5 f3 54 10 61
What am I doing wrong ?
Do you have an example of writing the public key to disk in DER or ascii armored format? I have been unsuccessful inspecting keys generated with eccrypto. I'm using nodejs.
var crypto = require("crypto");
var eccrypto = require("eccrypto");
var fs = require('fs');
// A new random 32-byte private key.
var privateKey = crypto.randomBytes(32);
// Corresponding uncompressed (65-byte) public key.
var publicKey = eccrypto.getPublic(privateKey);
fs.writeFile("public_key", publicKey, function(err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
openssl ec -inform DER -in public_key -pubin
read EC key
unable to load Key
14938:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:/SourceCache/OpenSSL098/OpenSSL098-52.10.1/src/crypto/asn1/asn1_lib.c:153:
There is no support for point compressed public keys (33 bytes instead of 65). This would be very useful.
Hi there,
First thanks for the amazing effort in this pakcage, it's really saving my day.
Well here seems to be some problems with my code.
what I can do:
- import a privateKey
- use it to generate a new publicKey, and de/encrypt works like a charming.
what I want:
- import the publicKey and the privateKey at the same time
- use them to de/encrypt, don't have to generate a new one
The code under blow is as far as I can get. It's a bit of ugly, please don't laugh at me for me being a rookie.
var keyUtils = require('js-crypto-key-utils');
var eccrypto = require("eccrypto");
var privKeyA = `-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgYYZNfKK0D3KJUE45
m7mBYQsH+iOu3IuzwK2W21/3lQChRANCAAT0SdzISybvGSWhwokYCndUAYwSPIkE
LuvZ2y9CBGO6PGGRvWJTvklrMfaALSxFlcXpdSfnB5ieBrht+qspmGBC
-----END PRIVATE KEY-----`;
var pubKeyA = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9EncyEsm7xklocKJGAp3VAGMEjyJ
BC7r2dsvQgRjujxhkb1iU75JazH2gC0sRZXF6XUn5weYnga4bfqrKZhgQg==
-----END PUBLIC KEY-----`;
const pubKeyObjFromPemA = new keyUtils.Key('pem', pubKeyA);
// console.log(pubKeyObjFromPemA);
const prvKeyObjFromPemA = new keyUtils.Key('pem', privKeyA);
// console.log(prvKeyObjFromPemA);
async function foo() {
let prvKeyJWKA = await prvKeyObjFromPemA.export('oct');
let pubKeyJWKA = await pubKeyObjFromPemA.export('oct');
// console.log(prvKeyJWKA);
// console.log(pubKeyJWKA);
// let pubAHex = Array.prototype.map.call(pubKeyJWKA, x => ('00' + x.toString(16)).slice(-2)).join('');
var privateKeyA = Buffer.from(prvKeyJWKA);
var publicKeyA = Buffer.from(pubKeyJWKA);
console.log(publicKeyA.toString('hex'));
let pubAHex = Array.prototype.map.call(publicKeyA, x => ('00' + x.toString(16)).slice(-2)).join('');
console.log(pubAHex);
publicKeyA = eccrypto.getPublic(privateKeyA);
console.log(publicKeyA.toString('hex'));
// Encrypting the message for A.
let encrypted = await eccrypto.encrypt(publicKeyA, Buffer.from("msg to a asdasdasdasd"));
console.log(encrypted.ciphertext.toString());
let plaintext = await eccrypto.decrypt(privateKeyA, encrypted);
console.log(plaintext.toString())
}
foo();
and here is what I got from the last run :
04f449dcc84b26ef1925a1c289180a7754018c123c89042eebd9db2f420463ba3c6191bd6253be496b31f6802d2c4595c5e97527e707989e06b86dfaab29986042
04f449dcc84b26ef1925a1c289180a7754018c123c89042eebd9db2f420463ba3c6191bd6253be496b31f6802d2c4595c5e97527e707989e06b86dfaab29986042
04f8d2d188ba947c54af0607e689258f2bdd7ab99027752975915b1baf56a9bf8c35c23fe2b0dc53999c60a963b317eabcd0bbdf612359906737d1173a1d386e0c
������ӆ�s������>�w�$���v�_�O)�d
msg to a asdasdasdasd
I really hope you may help me with this issue. Also if it's not happening by some reason, that's ok, I can just save another publicKey for the encryption using.
Thanks again for your time,
David
I'm trying to install gencryption npm package which relies on this one and I can't make it to install under windows.
I got vcpkg installed and ran the command to integrate the packages in a user-wide manner.
PS [12:17:16PM] C:\Users\uther\workspace# vcpkg integrate install
Applied user-wide integration for this vcpkg root.
All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
CMake projects should use -DCMAKE_TOOLCHAIN_FILE=C:/Users/uther/workspace/vcpkg/scripts/buildsystems/vcpkg.cmake
I can't install this package because of the linker error: LINK : fatal error LNK1181: cannot open input file 'C:\OpenSSL-Win64\lib\libeay32.lib' [C:\Users\uther\workspace\people-ai-worker\node_modules\eccrypto\build\ecdh.vcxproj]
(because obviously there's nothing there)
PS: I don't know what's the best practice when using external libs and windows
Hi,
I've been trying to use the getPublic function on a random private key just to try it out, but I keep getting the error "Bad private key".
Here's my code:
const privateKeyTest =
"0x8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f";
let privateKeyTable = [];
for (let i = 2; i < privateKeyTest.length; i = i + 2) {
const newElement = parseInt(privateKeyTest.slice(i, i + 2), 16);
privateKeyTable.push(newElement);
}
const TypedTable = Uint8Array.from(privateKeyTable);
console.log(TypedTable);
const publicKey = eccrypto.getPublic(TypedTable);
console.log(publicKey);
I've been able to use getPublic after eccrypto.generatePrivate(), and TypedTable is indeed a Uint8Array.
I also tried with a generated private key in hard code, such as this:
const TypedTable = new Uint8Array([
235,
78,
133,
244,
5,
163,
18,
32,
218,
162,
173,
132,
214,
16,
57,
100,
122,
48,
167,
30,
203,
69,
52,
48,
30,
99,
20,
32,
249,
210,
140,
48
]);
const publicKey = eccrypto.getPublic(TypedTable);
And it still does not work. Is there a reason why?
Thanks!
I realize this is most likely user error, but I was wondering if you could call out specifically which Browserify command and config you are using to get the payload output to run in a web env. Right now, no matter what I do, it complains that require
is not defined in browsers, and in Node it throws because there is no Web Crypto API present.
How can I load an existing openssl generated, .pem
encoded, private key to use with this lib?
Sorry if this is a stupid question...
What I tried was loading the base64 data and just loading it into a buffer, but as you mentioned that is just the DER encoded key. How can I decode that for use here?
Thanks!
To generate the private key I am using:
openssl ecparam -name secp256k1 -genkey -noout -out secp256k1-key.pem
I will also likely be generating the public key outside of this module, so I would like to load them not create them in code.
getRandomValues
of undefined error is raised on IE11 browser.
function randomBytes(size) {
var arr = new Uint8Array(size);
global.crypto.getRandomValues(arr);
return new Buffer(arr);
}
I think global.crypto needs to be replaced with cryptoObj in the randomBytes function. Any suggestions?
npm WARN deprecated [email protected]:
This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
Is it correct? Can you just use inbuilt crypto? @19h @JBaczuk JBaczuk @Kagami @ea2973929 @englercj @JBaczuk
In case if node native modules were failed to compile, we return browser implementation, but that only works for ECC because node doesn't provide WebCryptoAPI. We should just use elliptic (and wrap it accordingly) instead, since crypto module with symmetric ciphers should always be available in node.
router.post('/api/test', (req, res) => {
try {
var privateKeyB = eccrypto.generatePrivate();
var publicKeyB = eccrypto.getPublic(privateKeyB);
console.log("body data",req.body)
let body = JSON.parse(JSON.stringify(req.body))
console.log(body)
// Encrypting the message for B.
eccrypto.encrypt(publicKeyB, Buffer.from(body.data)).then((encrypted) => {
eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext) {
console.log("Message to part B:", plaintext.toString());
res.json({"msg": plaintext.toString()})
}).catch((e) => {
console.log("err while decrypting ",e)
res.statusCode(400).send(e)
});
}).catch((e) => {
console.log("err while encrypting ",e)
res.statusCode(400).send(e)
});
} catch (error) {
console.log("error try catch",error);
res.statusCode(400).send(error)
}
})
while my req.body.data parameter length is greater then 14 its breaking.
In the README, it says:
Only secp256k1 curve, only SHA-512 (KDF), HMAC-SHA-256 (HMAC) and AES-256-CBC for ECIES
and then it says:
Also WebCryptoAPI currently defines only curves recommended by NIST meaning that secp256k1 (K-256) curve is not supported (see also: [1], [2]).
Is this library using secp256k1 or not?
There's a link after that with text "seck256k1" that actually points to https://www.npmjs.com/package/secp256k1
So, which curve does this library use?
Is it possible to call getPublic
from a hex value private key?
I'm finding that it is requiring a Buffer
array, but Buffer
is not defined on the browser.
Any workaround for this? Thanks!
Installing eccrypto on nodejs version 12 will break on the build.
node -v
> v12.7.0
It can be reproduced by running npm install eccrypto
in an empty project.
Error output:
make: Entering directory '/home/dnl/workspace/test/node_modules/secp256k1/build'
CXX(target) Release/obj.target/secp256k1/src/addon.o
In file included from ../../nan/nan_converters.h:67:0,
from ../../nan/nan.h:221,
from ../src/addon.cc:2:
../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ToFactoryBase<v8::Boolean>::return_t Nan::imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value>)’:
../../nan/nan_converters_43_inl.h:18:51: warning: ‘v8::MaybeLocal<v8::Boolean> v8::Value::ToBoolean(v8::Local<v8::Context>) const’ is deprecated: ToBoolean can never throw. Use Local version. [-Wdeprecated-declarations]
val->To ## TYPE(isolate->GetCurrentContext()) \
^
../../nan/nan_converters_43_inl.h:22:1: note: in expansion of macro ‘X’
X(Boolean)
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2531:59: note: declared here
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../../nan/nan_converters.h:67:0,
from ../../nan/nan.h:221,
from ../src/addon.cc:2:
../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ValueFactoryBase<bool>::return_t Nan::imp::ToFactory<bool>::convert(v8::Local<v8::Value>)’:
../../nan/nan_converters_43_inl.h:37:57: warning: ‘v8::Maybe<bool> v8::Value::BooleanValue(v8::Local<v8::Context>) const’ is deprecated: BooleanValue can never throw. Use Isolate version. [-Wdeprecated-declarations]
return val->NAME ## Value(isolate->GetCurrentContext()); \
^
../../nan/nan_converters_43_inl.h:40:1: note: in expansion of macro ‘X’
X(bool, Boolean)
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2569:51: note: declared here
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../../nan/nan_new.h:189:0,
from ../../nan/nan.h:222,
from ../src/addon.cc:2:
../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
../../nan/nan_implementation_12_inl.h:105:32: error: no matching function for call to ‘v8::Function::New(v8::Isolate*&, void (&)(const v8::FunctionCallbackInfo<v8::Value>&), v8::Local<v8::Object>&)’
, obj));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63:0,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:4132:31: note: candidate: static v8::MaybeLocal<v8::Function> v8::Function::New(v8::Local<v8::Context>, v8::FunctionCallback, v8::Local<v8::Value>, int, v8::ConstructorBehavior, v8::SideEffectType)
static MaybeLocal<Function> New(
^~~
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:4132:31: note: no known conversion for argument 1 from ‘v8::Isolate*’ to ‘v8::Local<v8::Context>’
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In constructor ‘Nan::Utf8String::Utf8String(v8::Local<v8::Value>)’:
../../nan/nan.h:1064:78: warning: ‘v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2551:31: note: declared here
Local<String> ToString(Isolate* isolate) const);
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(const char*, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1855:64: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(New(key).ToLocalChecked(), value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3366:26: note: declared here
bool Set(Local<Value> key, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(const v8::Local<v8::String>&, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1861:42: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(key, value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3366:26: note: declared here
bool Set(Local<Value> key, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(uint32_t, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1867:44: warning: ‘bool v8::Object::Set(uint32_t, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(index, value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3375:26: note: declared here
bool Set(uint32_t index, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(const char*) const’:
../../nan/nan.h:1873:61: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Get(New(key).ToLocalChecked()));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3419:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(const v8::Local<v8::String>&) const’:
../../nan/nan.h:1879:55: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
return scope.Escape(New(persistentHandle)->Get(key));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3419:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../src/addon.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(uint32_t) const’:
../../nan/nan.h:1884:57: warning: ‘v8::Local<v8::Value> v8::Object::Get(uint32_t)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
return scope.Escape(New(persistentHandle)->Get(index));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3423:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /home/dnl/.node-gyp/12.7.0/include/node/node_object_wrap.h:26,
from ../../nan/nan.h:54,
from ../src/addon.cc:2:
../../nan/nan_object_wrap.h: In destructor ‘virtual Nan::ObjectWrap::~ObjectWrap()’:
../../nan/nan_object_wrap.h:24:25: error: ‘class Nan::Persistent<v8::Object>’ has no member named ‘IsNearDeath’
assert(persistent().IsNearDeath());
^
In file included from ../../nan/nan.h:2698:0,
from ../src/addon.cc:2:
../../nan/nan_object_wrap.h: In member function ‘void Nan::ObjectWrap::MakeWeak()’:
../../nan/nan_object_wrap.h:67:34: warning: ‘void v8::PersistentBase<T>::MarkIndependent() [with T = v8::Object]’ is deprecated: Weak objects are always considered independent. Use TracedGlobal when trying to use EmbedderHeapTracer. Use a strong handle when trying to keep an object alive. [-Wdeprecated-declarations]
persistent().MarkIndependent();
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../src/addon.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:567:22: note: declared here
V8_INLINE void MarkIndependent());
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /home/dnl/.node-gyp/12.7.0/include/node/node_object_wrap.h:26,
from ../../nan/nan.h:54,
from ../src/addon.cc:2:
../../nan/nan_object_wrap.h: In static member function ‘static void Nan::ObjectWrap::WeakCallback(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’:
../../nan/nan_object_wrap.h:124:26: error: ‘class Nan::Persistent<v8::Object>’ has no member named ‘IsNearDeath’
assert(wrap->handle_.IsNearDeath());
^
secp256k1.target.mk:158: recipe for target 'Release/obj.target/secp256k1/src/addon.o' failed
make: *** [Release/obj.target/secp256k1/src/addon.o] Error 1
make: Leaving directory '/home/dnl/workspace/test/node_modules/secp256k1/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:266:23)
gyp ERR! stack at ChildProcess.emit (events.js:203:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.15.0-54-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dnl/workspace/test/node_modules/secp256k1
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dnl/.npm/_logs/2019-08-03T21_14_51_562Z-debug.log
> [email protected] install /home/dnl/workspace/test/node_modules/eccrypto
> node-gyp rebuild || exit 0
make: Entering directory '/home/dnl/workspace/test/node_modules/eccrypto/build'
CXX(target) Release/obj.target/ecdh/ecdh.o
In file included from ../../nan/nan_converters.h:67:0,
from ../../nan/nan.h:221,
from ../ecdh.cc:2:
../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ToFactoryBase<v8::Boolean>::return_t Nan::imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value>)’:
../../nan/nan_converters_43_inl.h:18:51: warning: ‘v8::MaybeLocal<v8::Boolean> v8::Value::ToBoolean(v8::Local<v8::Context>) const’ is deprecated: ToBoolean can never throw. Use Local version. [-Wdeprecated-declarations]
val->To ## TYPE(isolate->GetCurrentContext()) \
^
../../nan/nan_converters_43_inl.h:22:1: note: in expansion of macro ‘X’
X(Boolean)
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2531:59: note: declared here
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../../nan/nan_converters.h:67:0,
from ../../nan/nan.h:221,
from ../ecdh.cc:2:
../../nan/nan_converters_43_inl.h: In static member function ‘static Nan::imp::ValueFactoryBase<bool>::return_t Nan::imp::ToFactory<bool>::convert(v8::Local<v8::Value>)’:
../../nan/nan_converters_43_inl.h:37:57: warning: ‘v8::Maybe<bool> v8::Value::BooleanValue(v8::Local<v8::Context>) const’ is deprecated: BooleanValue can never throw. Use Isolate version. [-Wdeprecated-declarations]
return val->NAME ## Value(isolate->GetCurrentContext()); \
^
../../nan/nan_converters_43_inl.h:40:1: note: in expansion of macro ‘X’
X(bool, Boolean)
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2569:51: note: declared here
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../../nan/nan_new.h:189:0,
from ../../nan/nan.h:222,
from ../ecdh.cc:2:
../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
../../nan/nan_implementation_12_inl.h:105:32: error: no matching function for call to ‘v8::Function::New(v8::Isolate*&, void (&)(const v8::FunctionCallbackInfo<v8::Value>&), v8::Local<v8::Object>&)’
, obj));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63:0,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:4132:31: note: candidate: static v8::MaybeLocal<v8::Function> v8::Function::New(v8::Local<v8::Context>, v8::FunctionCallback, v8::Local<v8::Value>, int, v8::ConstructorBehavior, v8::SideEffectType)
static MaybeLocal<Function> New(
^~~
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:4132:31: note: no known conversion for argument 1 from ‘v8::Isolate*’ to ‘v8::Local<v8::Context>’
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In constructor ‘Nan::Utf8String::Utf8String(v8::Local<v8::Value>)’:
../../nan/nan.h:1064:78: warning: ‘v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const’ is deprecated: Use maybe version [-Wdeprecated-declarations]
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:2551:31: note: declared here
Local<String> ToString(Isolate* isolate) const);
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(const char*, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1855:64: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(New(key).ToLocalChecked(), value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3366:26: note: declared here
bool Set(Local<Value> key, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(const v8::Local<v8::String>&, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1861:42: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(key, value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3366:26: note: declared here
bool Set(Local<Value> key, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SaveToPersistent(uint32_t, const v8::Local<v8::Value>&)’:
../../nan/nan.h:1867:44: warning: ‘bool v8::Object::Set(uint32_t, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Set(index, value);
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3375:26: note: declared here
bool Set(uint32_t index, Local<Value> value));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(const char*) const’:
../../nan/nan.h:1873:61: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
New(persistentHandle)->Get(New(key).ToLocalChecked()));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3419:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(const v8::Local<v8::String>&) const’:
../../nan/nan.h:1879:55: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
return scope.Escape(New(persistentHandle)->Get(key));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3419:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from ../ecdh.cc:2:0:
../../nan/nan.h: In member function ‘v8::Local<v8::Value> Nan::AsyncWorker::GetFromPersistent(uint32_t) const’:
../../nan/nan.h:1884:57: warning: ‘v8::Local<v8::Value> v8::Object::Get(uint32_t)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
return scope.Escape(New(persistentHandle)->Get(index));
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:3423:55: note: declared here
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:326:3: note: in definition of macro ‘V8_DEPRECATE_SOON’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /home/dnl/.node-gyp/12.7.0/include/node/node_object_wrap.h:26,
from ../../nan/nan.h:54,
from ../ecdh.cc:2:
../../nan/nan_object_wrap.h: In destructor ‘virtual Nan::ObjectWrap::~ObjectWrap()’:
../../nan/nan_object_wrap.h:24:25: error: ‘class Nan::Persistent<v8::Object>’ has no member named ‘IsNearDeath’
assert(persistent().IsNearDeath());
^
In file included from ../../nan/nan.h:2698:0,
from ../ecdh.cc:2:
../../nan/nan_object_wrap.h: In member function ‘void Nan::ObjectWrap::MakeWeak()’:
../../nan/nan_object_wrap.h:67:34: warning: ‘void v8::PersistentBase<T>::MarkIndependent() [with T = v8::Object]’ is deprecated: Weak objects are always considered independent. Use TracedGlobal when trying to use EmbedderHeapTracer. Use a strong handle when trying to keep an object alive. [-Wdeprecated-declarations]
persistent().MarkIndependent();
^
In file included from /home/dnl/.node-gyp/12.7.0/include/node/v8-internal.h:14:0,
from /home/dnl/.node-gyp/12.7.0/include/node/v8.h:25,
from /home/dnl/.node-gyp/12.7.0/include/node/node.h:63,
from ../ecdh.cc:1:
/home/dnl/.node-gyp/12.7.0/include/node/v8.h:567:22: note: declared here
V8_INLINE void MarkIndependent());
^
/home/dnl/.node-gyp/12.7.0/include/node/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /home/dnl/.node-gyp/12.7.0/include/node/node_object_wrap.h:26,
from ../../nan/nan.h:54,
from ../ecdh.cc:2:
../../nan/nan_object_wrap.h: In static member function ‘static void Nan::ObjectWrap::WeakCallback(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’:
../../nan/nan_object_wrap.h:124:26: error: ‘class Nan::Persistent<v8::Object>’ has no member named ‘IsNearDeath’
assert(wrap->handle_.IsNearDeath());
^
../ecdh.cc: At global scope:
../ecdh.cc:6:11: error: ‘v8::Handle’ has not been declared
using v8::Handle;
^~~~~~
ecdh.target.mk:113: recipe for target 'Release/obj.target/ecdh/ecdh.o' failed
make: *** [Release/obj.target/ecdh/ecdh.o] Error 1
make: Leaving directory '/home/dnl/workspace/test/node_modules/eccrypto/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:266:23)
gyp ERR! stack at ChildProcess.emit (events.js:203:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.15.0-54-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dnl/workspace/test/node_modules/eccrypto
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/secp256k1):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `npm run rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ [email protected]
When building an application on a ARM64 architecture, I get the following error:
warning Error running install script for optional dependency: "/usr/src/app/node_modules/eccrypto/node_modules/secp256k1: Command failed.
Exit code: 1
Command: npm run rebuild
Arguments:
Directory: /usr/src/app/node_modules/eccrypto/node_modules/secp256k1
Output:
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1590498076665-0.6896239708228453/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> [email protected] rebuild /usr/src/app/node_modules/eccrypto/node_modules/secp256k1
> node-gyp rebuild
gyp: Undefined variable openssl_config_path in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.6.12-1-MANJARO
gyp ERR! command \"/usr/local/bin/node\" \"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
gyp ERR! cwd /usr/src/app/node_modules/eccrypto/node_modules/secp256k1
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The same build (Dockerfile) works on x86_64/amd64 architecture.
Chrome emulator appears to be failing.
02 09 2019 10:35:28.962:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
02 09 2019 10:35:30.965:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
02 09 2019 10:35:32.967:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.
When installing on Windows 10, I get an error:
C:\dev\path-protocol\node_modules\eccrypto\node_modules\secp256k1>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
'.' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to './utils/has_lib.sh gmpxx && ./utils/has_lib.sh gmp' returned exit status 1 while in binding.gyp. while
trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\dev\path-protocol\node_modules\eccrypto\node_modules\secp256k1
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script. ```
When I encrypt a message with this library, is it also signed to verify its authenticity later on?
I am trying to use it in an angular app, but always got problems
core.js:4002 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'slice' of undefined
TypeError: Cannot read property 'slice' of undefined
at Object../node_modules/readable-stream/lib/_stream_writable.js
Hello, im trying to create an public/private ecc keyPair address with openssl linux binaries, no problem, but when I sign something with linux with my priv key, im unable to verify signature in nodejs with public address and signature.
Any help?
Hello World
I am using eccrypto to generate key pair at the clien side (javascript)
and verify signature at the server side (java).
I noticed that there is always a prefix "04" added to public key using eccrypto.
example:
const privateKey = Buffer.from('e12c017eaada16e2355e85d52e366a99b6ef5b871e2a4ef15a33861cdfbc276e, 'hex')
const publicKey = eccrypto.getPublic(privateKey);
const publicKeyHex = publicKey.toString('hex')
/* returns 040497cee5d2317fed4a79aeb13a6e50958ba3b928319d185c3faf05a7e0e859c0e45bfe5cec402529b92f07cf2341c44f3ca954ad727f58dfe096e9c5cafda51e7d*/
Using java security from the same privateKey I got :
97cee5d2317fed4a79aeb13a6e50958ba3b928319d185c3faf05a7e0e859c0e45bfe5cec402529b92f07cf2341c44f3ca954ad727f58dfe096e9c5cafda51e7d
without leading "04"
I tried many examples and always there is a leading "04"
any explantation please ?
I am searching an ECIES algorithm which can work fine both in client and server. My server is using Java, and the algorithm provider is bouncycastle. Is there any sample encrypting by javascript and decrypting by java?
I am committing a USD 200 bounty for help that solves this issue.
I would suggest that in order to verify the compatibility of the library with the various trargetted browsers and in order to keep track of various code quality indicator you could implement integration with Saucelabs and Codeclimate
i'm thinking this while evaluating the validity of the eccrypto for the integration in openpgp.js (openpgpjs/openpgpjs#428), and i've right know implemented what i'm suggesting to you for the https://github.com/indutny/elliptic project: indutny/elliptic#80
It would be great if you could do the same!
In examples on how to use eccrypto, private keys are often generated using
crypto.randomBytes(32)
Within the source code of eccrypto it's noted though that this might not be a valid keys and internally the following code is used for ephemPrivateKey:
while(!isValidPrivateKey(ephemPrivateKey))
{
ephemPrivateKey = opts.ephemPrivateKey || crypto.randomBytes(32);
}
function isValidPrivateKey(privateKey) {
if (!isScalar(privateKey))
{
return false;
}
return privateKey.compare(ZERO32) > 0 && // > 0
privateKey.compare(EC_GROUP_ORDER) < 0; // < G
}
As a user I would first of all need to know this, and secondly create my own function to do the same thing. isValidPrivateKey
is not exported.
It would be greatly appreciated if this could be abstracted away and provided in a function: eccrypto.generatePrivateKey()
. Alternatively at least isValidPrivateKey
could be exported.
Currently it builds with older versions of node, firefox, and g++
Hello. So I have been trying to post the encrypted message as a string hex value to an api and when I retrieve it, buffer the object, and decrypt, it gives me "bad public key". I am not sure why this happens, but how can I effectively store a message as json on an api and fetch it back for client siding decryption?
Please release files to some CDN using a process that supports file integrity.
Which domain parameters are used by default? Is it possible to set custom domain parameters?
I would like to use Sec256k1 standard used by Bitcoin as it is quite popular.
The elliptic module's readme links to http://safecurves.cr.yp.to/ which lists secp256k1 as not safe. Can I use other curves from elliptic, eg. ed25519?
Hi,
I have problem with ECIES decrypter. I have very specific case, in which I want to decrypt some data from foreign source(c++ library). We have: encrypted data in Buffer, PrivateKey and IV, but we don't have MAC. Is there any posibility to decrypt data without encrypting erlier with eccrypto?
Best regards!
let's say i'm using webcryptography in the browser and have some code like this:
var payload = {}
var combo = JSON.stringify({ ... })
var ab2b = function (ab) {
var buffer = []
var view = new Uint8Array(ab)
for (var i = 0; i < ab.byteLength; i++) buffer[i] = view[i]
return buffer
}
var s2ab = function (s) {
var buffer = new Uint8Array(s.length)
for (var i = 0; i < s.length; i++) buffer[i] = s.charCodeAt(i)
return buffer
}
var to_hex = function (bs) {
var encoded = []
for (var i = 0; i < bs.length; i++) {
encoded.push('0123456789abcdef'[(bs[i] >> 4) & 15])
encoded.push('0123456789abcdef'[bs[i] & 15])
}
return encoded.join('')
}
window.crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' },
true, [ 'sign', 'verify' ]).then(function (pair) {
window.crypto.subtle.exportKey('raw', pair.publicKey).then(function (publicKey) {
window.crypto.subtle.sign({ name: 'ECDSA', hash: { name: 'SHA-256' } },
pair.privateKey, s2ab(combo)).then(function(signature) {
payload.publicKey = to_hex(ab2b(publickKey)
payload.signature = to_hex(ab2b(signature)
})
})
})
what i am trying to figure out is how to take the two values in payload that contain hex-encoded strings and invoke ecdsa.verify() appropriately:
var crypto = require('crypto')
var ecdsa = require('eccrypto')
var reverse = function(s) {
var array = []
for (var i = s.length - 2; i >= 0; i -= 2) array.push(s.substr(i, 2))
return array.join('')
}
var from_hex = function (s) {
var i, result
if (!s) s = ''
result = new Uint8Array(s.length / 2)
for (i = 0; i < s.length / 2; i++) result[i] = parseInt(s.substr(i * 2, 2), 16)
return result
}
var userId = '213B6A73-4A53-4E63-BEDB-26AB2C8AA227'
, message =
{
"header": {
"signature": "11e05bb6c5cc0980d8611a1e7921423b0aa6a3440257a7ed984aab4ffc5034fe0abce2e9e03b41f7544deecb3eac2315f6027a6676ef706dcb8737913355af34",
"nonce": "1449333073.463"
},
"payload": {
"version": 1,
"publicKey": "04cb67681175709c99baba9514094078028857ec8633d6273886222bee7a604a4c721743c7344498792c5f1f78aabfa03805d28c4544cfe3ed63dabde10bc529d9"
}
}
, combo = JSON.stringify({ userId: userId, nonce: message.header.nonce, payload: message.payload })
, r = message.header.signature.substr(0, 64)
, s = message.header.signature.substr(64, 64)
, options =
{ r: reverse(r)
, s: reverse(s)
}
console.log(options)
ecdsa.verify(from_hex(message.payload.publicKey), crypto.createHash('sha256').update(combo).digest(),
options).then(function () {
console.log('winner')
}).catch(function (ex) {
console.log('loser')
console.log(ex)
})
thanks!
/mtr
In binding.gyp, the Windows sections root folder should be c:\Porgram Files\OpenSSL-Win64
or c:\Porgram Files(x86)\OpenSSL-Win32
- those are the standard folders where OpenSSL installs by default. Forcing devs to install it in the top level folder is not a good practice.
eccryptoJS.encrypt() requires a Buffer and rejects a Uint8Array, while the originial eccrypto (https://github.com/bitchan/eccrypto) can accept both. This causes my app crash.
IMHO, Uint8Array is better than Buffer since Buffer is invalid in browser.
I'm trying to use this package for a Chrome extension. However, they don't allow the use of "require" statements.
I'm trying to add it as a simple JS file but keep getting the error "require is not defined." I even tried creating a build with Webpack but that got the same error (target = web
)
Curious if anyone has any suggestions?
Hi,
I'm building an application that requires a private key to be encrypted/decrypted with a passphrase. As this is not currently a feature, what advice would you give me regarding how I should go about this? Planning on obviously pushing any changes I make privately to enhance this.
Thanks
Hi
I want to generate bitcoin private key from a 512 bit seed.
can I do this with your library and how ?
please give me example
Providing the binary for this module would save a lot of time when installing it (time to install the build dependencies, time to build the code, time to clean the build dependencies) and some space in the docker layers (an extra layer with build dependencies).
90% of my npm -ci
is dedicated to this module on many projects.
Would you be open to considering something like https://github.com/mapbox/node-pre-gyp ?
Create the benchmark to test the performance differences between:
Also measure how much performance we lose when create new KeyPair instance for each sign/verify operation (elliptic only).
The decryption failed with the "Bad MAC" error on the browser. This is happening on 'eth-crypto' module which uses this as a dependency.
This case happens only like ~ 1/300 cases. Rest 299 decrypt with perfectly fine on the browser itself.
Even the cases that failed on browser are being able to decrypt on Node easily without any problems. Points me to check the newer builds.
We are using Webpack and have been using this same module the same version for more than a year. and this started recently. I am trying to trace right now but any help would be appreciated.
Thank you for your time.
Ref ticket for Eth-crypto: https://github.com/pubkey/eth-crypto/issues/281
Hello,
I've got a problem with the ECDSA Sign function. It should return always different signatures due to the K value, but it doesn't - its always the same. How can I change that manually?
Best regards,
Luke
I'm using eccrypto in both browser & node in a system and am observing a decryption failure. In the browser I'm encountering this error with specific data (so far this has been replicated once in about 1000+ uses
decryption-problem.zip
):
"Uncaught Error: The error you provided does not contain a stack trace."
When I move the same data and use case to node, I get the following error:
Failed with error: Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
at Decipheriv.final (internal/crypto/cipher.js:183:29)
at aes256CbcDecrypt (/Users/.../node_modules/eccrypto/index.js:61:28)
at /Users/.../node_modules/eccrypto/index.js:256:66
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async tryDecrypting (/Users/.../index.js:44:18) {
library: 'digital envelope routines',
function: 'EVP_DecryptFinal_ex',
reason: 'bad decrypt',
code: 'ERR_OSSL_EVP_BAD_DECRYPT'
}
The associated private key was created using the eccrypto library on a browser, here is what that code looks like:
const priKey = eccrypto.generatePrivate()
const pubKey = eccrypto.getPublic(priKey)
This works most of the time (i.e. upwards of 1/1000), however I'd like to understand this particular failure as this rate of failure is still too high.
One important note is that private keys are being encrypted/decrypted on an HSM and stored in binary on a DB. Also the cipher text object is being stored in binary on a DB. We could change that to base 64 and possibly look at applying ECC or other techniques to ensure data integrity, but it's not clear to me that is the issue.
I've attached an example node project with the failing data (key and ciphertext). To run it:
Hi !
First thing i want to say thank you for your amazing library.
Currently i have trouble. I use this library to generate public and private key on node server, then return to android client public key. I import success public key and verify complete in android client, but when i use public key for encrypt (ECIES) and post to node server to decrypt it, node server throw bad public key exception.
I hope will receive your reply soon !
Thanks !
All keys and input must be validated before any processing in order to avoid implementation specific vulnerabilities against corrupted input parameters.
See http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript, cryptocoinjs/eckey#13.
We should exactly understand what's going on if secret key is >= n
.
Blocker issue: cryptocoinjs/secp256k1-node#33
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.