本文整理汇总了Java中net.i2p.crypto.eddsa.spec.EdDSAParameterSpec类的典型用法代码示例。如果您正苦于以下问题:Java EdDSAParameterSpec类的具体用法?Java EdDSAParameterSpec怎么用?Java EdDSAParameterSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdDSAParameterSpec类属于net.i2p.crypto.eddsa.spec包,在下文中一共展示了EdDSAParameterSpec类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSign
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
@Test
public void testSign() throws Exception {
//Signature sgr = Signature.getInstance("EdDSA", "I2P");
Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
for (Ed25519TestVectors.TestTuple testCase : Ed25519TestVectors.testCases) {
EdDSAPrivateKeySpec privKey = new EdDSAPrivateKeySpec(testCase.seed, spec);
PrivateKey sKey = new EdDSAPrivateKey(privKey);
sgr.initSign(sKey);
sgr.update(testCase.message);
assertThat("Test case " + testCase.caseNum + " failed",
sgr.sign(), is(equalTo(testCase.sig)));
}
}
示例2: testVerify
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
@Test
public void testVerify() throws Exception {
//Signature sgr = Signature.getInstance("EdDSA", "I2P");
Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
for (Ed25519TestVectors.TestTuple testCase : Ed25519TestVectors.testCases) {
EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(testCase.pk, spec);
PublicKey vKey = new EdDSAPublicKey(pubKey);
sgr.initVerify(vKey);
sgr.update(testCase.message);
assertThat("Test case " + testCase.caseNum + " failed",
sgr.verify(testCase.sig), is(true));
}
}
示例3: EdsaSigner
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
public EdsaSigner(byte[] privateKeyBytes) {
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
EdDSAPrivateKeySpec privateKeySpec = new EdDSAPrivateKeySpec(privateKeyBytes, spec);
EdDSAPublicKeySpec pubKeySpec = new EdDSAPublicKeySpec(privateKeySpec.getA(), spec);
publicKey = new EdDSAPublicKey(pubKeySpec);
privateKey = new EdDSAPrivateKey(privateKeySpec);
}
示例4: initialize
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
if (params instanceof EdDSAParameterSpec) {
edParams = (EdDSAParameterSpec) params;
} else if (params instanceof EdDSAGenParameterSpec) {
edParams = createNamedCurveSpec(((EdDSAGenParameterSpec) params).getName());
} else
throw new InvalidAlgorithmParameterException("parameter object not a EdDSAParameterSpec");
this.random = random;
initialized = true;
}
示例5: cvtToJavaEdDSAKey
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
/**
* @since 0.9.15
*/
private static EdDSAPublicKey cvtToJavaEdDSAKey(SigningPublicKey pk)
throws GeneralSecurityException {
try {
return new EdDSAPublicKey(new EdDSAPublicKeySpec(
pk.getData(), (EdDSAParameterSpec) pk.getType().getParams()));
} catch (IllegalArgumentException iae) {
throw new InvalidKeyException(iae);
}
}
示例6: getSpecs
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
public EdDSAParameterSpec getSpecs() {
return keySpecs;
}
示例7: getParams
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
public EdDSAParameterSpec getParams() {
return edDsaSpec;
}
示例8: generateKey
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
public static byte[] generateKey() throws InvalidAlgorithmParameterException {
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
byte[] seed = new byte[spec.getCurve().getField().getb()/8];
getSecureRandom().nextBytes(seed);
return seed;
}
示例9: EdsaVerifier
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
public EdsaVerifier(byte[] publicKey) {
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(publicKey, spec);
this.publicKey = new EdDSAPublicKey(pubKey);
}
示例10: getParams
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
@Override
public EdDSAParameterSpec getParams() {
return edDsaSpec;
}
示例11: getParams
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
/**
* return a parameter specification representing the EdDSA domain
* parameters for the key.
*/
public EdDSAParameterSpec getParams();
示例12: getParams
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; //导入依赖的package包/类
/**
* @return a parameter specification representing the EdDSA domain
* parameters for the key.
*/
EdDSAParameterSpec getParams();