本文整理汇总了Java中org.bitcoinj.core.ECKey.ECDSASignature类的典型用法代码示例。如果您正苦于以下问题:Java ECDSASignature类的具体用法?Java ECDSASignature怎么用?Java ECDSASignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ECDSASignature类属于org.bitcoinj.core.ECKey包,在下文中一共展示了ECDSASignature类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isInputStandard
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */
public static RuleViolation isInputStandard(TransactionInput input) {
for (ScriptChunk chunk : input.getScriptSig().getChunks()) {
if (chunk.data != null && !chunk.isShortestPossiblePushData())
return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
if (chunk.isPushData()) {
ECDSASignature signature;
try {
signature = ECKey.ECDSASignature.decodeFromDER(chunk.data);
} catch (IllegalArgumentException x) {
// Doesn't look like a signature.
signature = null;
}
if (signature != null) {
if (!TransactionSignature.isEncodingCanonical(chunk.data))
return RuleViolation.SIGNATURE_CANONICAL_ENCODING;
if (!signature.isCanonical())
return RuleViolation.SIGNATURE_CANONICAL_ENCODING;
}
}
}
return RuleViolation.NONE;
}
开发者ID:guodroid,项目名称:okwallet,代码行数:24,代码来源:DefaultRiskAnalysis.java
示例2: isInputStandard
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */
public static RuleViolation isInputStandard(TransactionInput input) {
for (ScriptChunk chunk : input.getScriptSig().getChunks()) {
if (chunk.data != null && !chunk.isShortestPossiblePushData())
return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
if (chunk.isPushData()) {
ECDSASignature signature;
try {
signature = ECKey.ECDSASignature.decodeFromDER(chunk.data);
} catch (RuntimeException x) {
// Doesn't look like a signature.
signature = null;
}
if (signature != null) {
if (!TransactionSignature.isEncodingCanonical(chunk.data))
return RuleViolation.SIGNATURE_CANONICAL_ENCODING;
if (!signature.isCanonical())
return RuleViolation.SIGNATURE_CANONICAL_ENCODING;
}
}
}
return RuleViolation.NONE;
}
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:24,代码来源:DefaultRiskAnalysis.java
示例3: keyRecovery
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
@Test
public void keyRecovery() throws Exception {
ECKey key = new ECKey();
String message = "Hello World!";
Sha256Hash hash = Sha256Hash.of(message.getBytes());
ECKey.ECDSASignature sig = key.sign(hash);
key = ECKey.fromPublicOnly(key.getPubKeyPoint());
boolean found = false;
for (int i = 0; i < 4; i++) {
ECKey key2 = ECKey.recoverFromSignature(i, sig, hash, true);
checkNotNull(key2);
if (key.equals(key2)) {
found = true;
break;
}
}
assertTrue(found);
}
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:19,代码来源:ECKeyTest.java
示例4: keyRecoveryWithEncryptedKey
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
@Test
public void keyRecoveryWithEncryptedKey() throws Exception {
ECKey unencryptedKey = new ECKey();
KeyParameter aesKey = keyCrypter.deriveKey(PASSWORD1);
ECKey encryptedKey = unencryptedKey.encrypt(keyCrypter, aesKey);
String message = "Goodbye Jupiter!";
Sha256Hash hash = Sha256Hash.of(message.getBytes());
ECKey.ECDSASignature sig = encryptedKey.sign(hash, aesKey);
unencryptedKey = ECKey.fromPublicOnly(unencryptedKey.getPubKeyPoint());
boolean found = false;
for (int i = 0; i < 4; i++) {
ECKey key2 = ECKey.recoverFromSignature(i, sig, hash, true);
checkNotNull(key2);
if (unencryptedKey.equals(key2)) {
found = true;
break;
}
}
assertTrue(found);
}
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:22,代码来源:ECKeyTest.java
示例5: sValue
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
@Test
public void sValue() throws Exception {
// Check that we never generate an S value that is larger than half the curve order. This avoids a malleability
// issue that can allow someone to change a transaction [hash] without invalidating the signature.
final int ITERATIONS = 10;
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(ITERATIONS));
List<ListenableFuture<ECKey.ECDSASignature>> sigFutures = Lists.newArrayList();
final ECKey key = new ECKey();
for (byte i = 0; i < ITERATIONS; i++) {
final Sha256Hash hash = Sha256Hash.of(new byte[]{i});
sigFutures.add(executor.submit(new Callable<ECKey.ECDSASignature>() {
@Override
public ECKey.ECDSASignature call() throws Exception {
return key.sign(hash);
}
}));
}
List<ECKey.ECDSASignature> sigs = Futures.allAsList(sigFutures).get();
for (ECKey.ECDSASignature signature : sigs) {
assertTrue(signature.isCanonical());
}
final ECDSASignature first = sigs.get(0);
final ECKey.ECDSASignature duplicate = new ECKey.ECDSASignature(first.r, first.s);
assertEquals(first, duplicate);
assertEquals(first.hashCode(), duplicate.hashCode());
final ECKey.ECDSASignature highS = new ECKey.ECDSASignature(first.r, ECKey.CURVE.getN().subtract(first.s));
assertFalse(highS.isCanonical());
}
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:30,代码来源:ECKeyTest.java
示例6: getMultisigInputScript
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
public static Script getMultisigInputScript (ECDSASignature client, ECDSASignature server) {
ArrayList<TransactionSignature> signList = new ArrayList<TransactionSignature>();
signList.add(new TransactionSignature(client, SigHash.ALL, false));
signList.add(new TransactionSignature(server, SigHash.ALL, false));
Script inputScript = ScriptBuilder.createMultiSigInputScript(signList);
/*
* Seems there is a bug here,
* https://groups.google.com/forum/#!topic/bitcoinj/A9R8TdUsXms
*/
Script workaround = new Script(inputScript.getProgram());
return workaround;
}
开发者ID:blockchain,项目名称:thunder,代码行数:13,代码来源:Tools.java
示例7: getMultisigInputScript
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/**
* Gets the multisig input script.
*
* @param client the client
* @param server the server
* @return the multisig input script
*/
public static Script getMultisigInputScript (ECDSASignature client, ECDSASignature server) {
ArrayList<TransactionSignature> signList = new ArrayList<TransactionSignature>();
signList.add(new TransactionSignature(client, SigHash.ALL, false));
signList.add(new TransactionSignature(server, SigHash.ALL, false));
Script inputScript = ScriptBuilder.createMultiSigInputScript(signList);
/*
* Seems there is a bug here,
* https://groups.google.com/forum/#!topic/bitcoinj/A9R8TdUsXms
*/
Script workaround = new Script(inputScript.getProgram());
return workaround;
}
开发者ID:matsjj,项目名称:thundernetwork,代码行数:21,代码来源:Tools.java
示例8: isSignatureCorrect
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
private boolean isSignatureCorrect(ECDSASignature signature, byte[] challengeString) {
Sha256Hash hash = Sha256Hash.wrap(Sha256Hash.hash(challengeString));
ECKey verificationKey = ECKey.fromPublicOnly(partnerProof.getScriptPair().getPubKey());
return verificationKey.verify(hash, signature);
}
开发者ID:kit-tm,项目名称:bitnym,代码行数:6,代码来源:ChallengeResponseVerifier.java
示例9: sign
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
private ECDSASignature sign(Sha256Hash hash, ECKey signingKey) {
return signingKey.sign(hash);
}
开发者ID:kit-tm,项目名称:bitnym,代码行数:4,代码来源:ChallengeResponseVerifier.java
示例10: getSignature
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
public static TransactionSignature getSignature (Transaction transactionToSign, int index, byte[] outputToSpend, ECKey key) {
Sha256Hash hash = transactionToSign.hashForSignature(index, outputToSpend, SigHash.ALL, false);
ECDSASignature signature = key.sign(hash).toCanonicalised();
return new TransactionSignature(signature, SigHash.ALL, false);
}
开发者ID:matsjj,项目名称:thundernetwork,代码行数:7,代码来源:Tools.java
示例11: sign
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
public static String sign(ECKey key, String input) throws UnsupportedEncodingException {
byte[] data = input.getBytes("UTF8");
Sha256Hash hash = Sha256Hash.of(data);
ECDSASignature sig = key.sign(hash, null);
byte[] bytes = sig.encodeToDER();
return bytesToHex(bytes);
}
开发者ID:bitpay,项目名称:java-bitpay-client,代码行数:11,代码来源:KeyUtils.java
示例12: checkSignature
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/**
* Check signature.
*
* @param transaction the transaction
* @param index the index
* @param outputToSpend the output to spend
* @param key the key
* @param signature the signature
* @return true, if successful
*/
public static boolean checkSignature (Transaction transaction, int index, TransactionOutput outputToSpend, ECKey key, byte[] signature) {
Sha256Hash hash = transaction.hashForSignature(index, outputToSpend.getScriptBytes(), SigHash.ALL, false);
return key.verify(hash, ECDSASignature.decodeFromDER(signature));
}
开发者ID:blockchain,项目名称:thunder,代码行数:15,代码来源:Tools.java
示例13: TransactionWrapper
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/**
* Instantiates a new transaction wrapper.
*
* @param transaction the transaction
* @param signature the signature
*/
public TransactionWrapper (Transaction transaction, ECDSASignature signature) {
this.transaction = transaction;
this.signature = signature;
}
开发者ID:matsjj,项目名称:thundernetwork,代码行数:11,代码来源:TransactionWrapper.java
示例14: getSignature
import org.bitcoinj.core.ECKey.ECDSASignature; //导入依赖的package包/类
/**
* Gets the signature.
*
* @return the signature
*/
public ECDSASignature getSignature () {
return signature;
}
开发者ID:matsjj,项目名称:thundernetwork,代码行数:9,代码来源:TransactionWrapper.java
注:本文中的org.bitcoinj.core.ECKey.ECDSASignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论