We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code:
import java.io.BufferedReader; import java.io.FileReader; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.PrivateKey; import java.security.Signature; import java.util.Base64; import net.i2p.crypto.eddsa.Utils; import net.i2p.crypto.eddsa.EdDSAEngine; import net.i2p.crypto.eddsa.EdDSAPrivateKey; import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable; import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec; public class EdSignTest { // ed25519 final static EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519); public static void main(String[] args) throws Exception { byte[] ZERO_H = Utils.hexToBytes("39e6fb57062449a6a058f7117b3a3ac7e92fd23a6679bc23c882efe2cfb9b520d79a86ac2ebfe10add5e26bead8f6528e8d3b28785b2fe112fe3b78bac27787d"); String data = "lexar{\"status\": true}BWTbpxar9GPX6yl7H6C5bClxaBFhdxgd1622015270"; //Signature signature = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); EdDSAEngine signature = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); EdDSAPrivateKeySpec privKey = new EdDSAPrivateKeySpec(spec, ZERO_H); //new EdDSAPrivateKeySpec(privSeed, spec); PrivateKey sKey = new EdDSAPrivateKey(privKey); signature.initSign(sKey); byte[] msg = data.getBytes(StandardCharsets.UTF_8); System.out.println("msg.len:"+ msg.length); signature.update(msg); byte[] s = signature.sign(); System.out.println("DATA_HEX : " + Utils.bytesToHex(s)); String encodedString = Base64.getUrlEncoder().encodeToString(s); System.out.println("DATA : " + data); System.out.println("SIGN : " + encodedString); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
code:
The text was updated successfully, but these errors were encountered: