Git Product home page Git Product logo

Comments (6)

CryptoMathician avatar CryptoMathician commented on July 21, 2024

Or is it possible to store the generated key pair into the CryptoKeyPair object from the JS web crypto API [1]?
I am not sure, if that is possible.

Pascal

[1] https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey

from core.

mcarrickscott avatar mcarrickscott commented on July 21, 2024

In general I like to keep public and secret keys separate from one another. The public key can always be generated from the secret key if needed.

from core.

CryptoMathician avatar CryptoMathician commented on July 21, 2024

Ok. Do you maybe know, if it is possible to import the created key from the library into the CryptoKeyPair/CryptoKey to use the standardized methods for signatures? Or is it possible to do the same behavior as in java (below) with this library?

Signature sig = Signature.getInstance("SHA256withECDSA");
		sig.initSign(privateKey);
		for(byte[] bytes : message) {
			sig.update(bytes);
		}
		return sig.sign();

The method sig.sign() gives me an byte array, but with the

ECDH.ECPSP_DSA(sha, rng ,privateKey,message,CS, DS);

I get the signature in form of CSand DS. Is it possible to create a signature as it is in java (above)?
The message is defined as follows:

List<byte[]> message

Thank you in advance!

EDIT:
In general I want to sign a nonce and a uid with the private key and want to get a byte array back.

from core.

CryptoMathician avatar CryptoMathician commented on July 21, 2024

Have I only to convert the CS (I think that is the r value) and DS (I thin it is the s value) [1] to a DER format like this example [2]

3045022065A67F8FF9CB5EA8BE899E94CB338FE09E2E596BC047D936FC2B96DC013B5DFC022100BE123D3F143AF91E4551AAFAE49C9187F64E323F5660D6C6198A9446C3F818A1

DER encoding:
30 - Sequence
45 - 45 hex bytes (69 decimal)
02 - Integer
20 - 20 hex bytes (32 decimal)
65A67F8FF9CB5EA8BE899E94CB338FE09E2E596BC047D936FC2B96DC013B5DFC - 32 bytes integer signature (r)
02 - Integer
21 - 21 hex (33 decimal) bytes
00BE123D3F143AF91E4551AAFAE49C9187F64E323F5660D6C6198A9446C3F818A1 - 33 bytes integer signature (s)

or is there something more to do? I am not sure, but it seems to me that the Java Signature object gives a byte array back, which are in DER format.

[1] https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Signature_generation_algorithm
[2] https://crypto.stackexchange.com/questions/78248/difference-between-der-encoded-signatures-in-javascript-java-and-c

from core.

mcarrickscott avatar mcarrickscott commented on July 21, 2024

I am sure it is possible, it seems just a case of transforming the signature from one format to another, but I'm afraid I don't have the time to look into it right now...

from core.

CryptoMathician avatar CryptoMathician commented on July 21, 2024

Ok, thank you anyway!

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.