本文整理汇总了Java中net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec类的典型用法代码示例。如果您正苦于以下问题:Java EdDSANamedCurveSpec类的具体用法?Java EdDSANamedCurveSpec怎么用?Java EdDSANamedCurveSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdDSANamedCurveSpec类属于net.i2p.crypto.eddsa.spec包,在下文中一共展示了EdDSANamedCurveSpec类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructEd25519KeyPair
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec; //导入依赖的package包/类
/**
* Helper method to construct an instance of {@link KeyPair} containing keys for testing purposes.
*
* @return An instance of {@link KeyPair}.
*/
protected KeyPair constructEd25519KeyPair() throws InvalidKeySpecException {
final EdDSANamedCurveSpec edParams = EdDSANamedCurveTable
.getByName(CryptoConditionReader.ED_25519);
assert (edParams != null);
final EdDSAPublicKeySpec pubKeySpec = new EdDSAPublicKeySpec(TEST_PUBKEY, edParams);
final PublicKey pubKey = new EdDSAPublicKey(pubKeySpec);
final EdDSAPrivateKeySpec privateKeySpec = new EdDSAPrivateKeySpec(TEST_PRIVKEY, edParams);
final PrivateKey privKey = new EdDSAPrivateKey(privateKeySpec);
return new KeyPair(pubKey, privKey);
}
示例2: createNamedCurveSpec
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec; //导入依赖的package包/类
/**
* Create an EdDSANamedCurveSpec from the provided curve name. The current
* implementation fetches the pre-created curve spec from a table.
* @param curveName the EdDSA named curve.
* @return the specification for the named curve.
* @throws InvalidAlgorithmParameterException if the named curve is unknown.
*/
protected EdDSANamedCurveSpec createNamedCurveSpec(String curveName) throws InvalidAlgorithmParameterException {
EdDSANamedCurveSpec spec = EdDSANamedCurveTable.getByName(curveName);
if (spec == null) {
throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
}
return spec;
}
示例3: isValidSignature
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec; //导入依赖的package包/类
public boolean isValidSignature(byte[] message, byte[] signature, byte[] publicKey) {
try {
EdDSANamedCurveSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
EdDSAPublicKeySpec edDSAPublicKeySpec = new EdDSAPublicKeySpec(publicKey, spec);
EdDSAPublicKey edDSAPublicKey = new EdDSAPublicKey(edDSAPublicKeySpec);
mEdDSAEngine.initVerify(edDSAPublicKey);
mEdDSAEngine.update(message);
return mEdDSAEngine.verify(signature);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}