当前位置: 首页>>代码示例>>Java>>正文


Java Crypto.sign方法代码示例

本文整理汇总了Java中nxt.crypto.Crypto.sign方法的典型用法代码示例。如果您正苦于以下问题:Java Crypto.sign方法的具体用法?Java Crypto.sign怎么用?Java Crypto.sign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nxt.crypto.Crypto的用法示例。


在下文中一共展示了Crypto.sign方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sign

import nxt.crypto.Crypto; //导入方法依赖的package包/类
void sign(String secretPhrase) {
    if (blockSignature != null) {
        throw new IllegalStateException("Block already signed");
    }
    blockSignature = new byte[64];
    byte[] data = getBytes();
    byte[] data2 = new byte[data.length - 64];
    System.arraycopy(data, 0, data2, 0, data2.length);
    blockSignature = Crypto.sign(data2, secretPhrase);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:11,代码来源:BlockImpl.java

示例2: sign

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Override
public void sign(String secretPhrase) {
    if (signature != null) {
        throw new IllegalStateException("Transaction already signed");
    }
    signature = Crypto.sign(getBytes(), secretPhrase);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:8,代码来源:TransactionImpl.java

示例3: generateHallmark

import nxt.crypto.Crypto; //导入方法依赖的package包/类
public static String generateHallmark(String secretPhrase, String host, int weight, int date) {

        if (host.length() == 0 || host.length() > 100) {
            throw new IllegalArgumentException("Hostname length should be between 1 and 100");
        }
        if (weight <= 0 || weight > Constants.MAX_BALANCE_NXT) {
            throw new IllegalArgumentException("Weight should be between 1 and " + Constants.MAX_BALANCE_NXT);
        }

        byte[] publicKey = Crypto.getPublicKey(secretPhrase);
        byte[] hostBytes = Convert.toBytes(host);

        ByteBuffer buffer = ByteBuffer.allocate(32 + 2 + hostBytes.length + 4 + 4 + 1);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        buffer.put(publicKey);
        buffer.putShort((short)hostBytes.length);
        buffer.put(hostBytes);
        buffer.putInt(weight);
        buffer.putInt(date);

        byte[] data = buffer.array();
        data[data.length - 1] = (byte) ThreadLocalRandom.current().nextInt();
        byte[] signature = Crypto.sign(data, secretPhrase);

        return Convert.toHexString(data) + Convert.toHexString(signature);

    }
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:28,代码来源:Hallmark.java

示例4: BlockImpl

import nxt.crypto.Crypto; //导入方法依赖的package包/类
BlockImpl(int version, int timestamp, long previousBlockId, long totalAmountNQT, long totalFeeNQT, int payloadLength, byte[] payloadHash,
          byte[] generatorPublicKey, byte[] generationSignature, byte[] previousBlockHash, List<TransactionImpl> transactions, String secretPhrase) {
    this(version, timestamp, previousBlockId, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash,
            generatorPublicKey, generationSignature, null, previousBlockHash, transactions);
    blockSignature = Crypto.sign(bytes(), secretPhrase);
    bytes = null;
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:8,代码来源:BlockImpl.java

示例5: sign

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Override
public void sign(byte[] privateKey) {
    checkForSignature();
    signature = Crypto.sign(getBytes(), privateKey);
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:6,代码来源:TransactionImpl.java

示例6: TransactionImpl

import nxt.crypto.Crypto; //导入方法依赖的package包/类
private TransactionImpl(BuilderImpl builder, String secretPhrase) throws NxtException.NotValidException {

        this.timestamp = builder.timestamp;
        this.deadline = builder.deadline;
        this.senderPublicKey = builder.senderPublicKey;
        this.recipientId = builder.recipientId;
        this.amountNQT = builder.amountNQT;
        this.referencedTransactionFullHash = builder.referencedTransactionFullHash;
        this.type = builder.type;
        this.version = builder.version;
        this.blockId = builder.blockId;
        this.height = builder.height;
        this.index = builder.index;
        this.id = builder.id;
        this.senderId = builder.senderId;
        this.blockTimestamp = builder.blockTimestamp;
        this.fullHash = builder.fullHash;
		this.ecBlockHeight = builder.ecBlockHeight;
        this.ecBlockId = builder.ecBlockId;

        List<Appendix.AbstractAppendix> list = new ArrayList<>();
        if ((this.attachment = builder.attachment) != null) {
            list.add(this.attachment);
        }
        if ((this.message  = builder.message) != null) {
            list.add(this.message);
        }
        if ((this.encryptedMessage = builder.encryptedMessage) != null) {
            list.add(this.encryptedMessage);
        }
        if ((this.publicKeyAnnouncement = builder.publicKeyAnnouncement) != null) {
            list.add(this.publicKeyAnnouncement);
        }
        if ((this.encryptToSelfMessage = builder.encryptToSelfMessage) != null) {
            list.add(this.encryptToSelfMessage);
        }
        if ((this.phasing = builder.phasing) != null) {
            list.add(this.phasing);
        }
        if ((this.prunablePlainMessage = builder.prunablePlainMessage) != null) {
            list.add(this.prunablePlainMessage);
        }
        if ((this.prunableEncryptedMessage = builder.prunableEncryptedMessage) != null) {
            list.add(this.prunableEncryptedMessage);
        }
        this.appendages = Collections.unmodifiableList(list);
        int appendagesSize = 0;
        for (Appendix appendage : appendages) {
            if (secretPhrase != null && appendage instanceof Appendix.Encryptable) {
                ((Appendix.Encryptable)appendage).encrypt(secretPhrase);
            }
            appendagesSize += appendage.getSize();
        }
        this.appendagesSize = appendagesSize;
        if (builder.feeNQT <= 0) {
            int effectiveHeight = (height < Integer.MAX_VALUE ? height : Nxt.getBlockchain().getHeight());
            if (this.phasing == null) {
                feeNQT = getMinimumFeeNQT(effectiveHeight);
            } else {
                feeNQT = Math.max(getMinimumFeeNQT(effectiveHeight), getMinimumFeeNQT(phasing.getFinishHeight()));
            }
        } else {
            feeNQT = builder.feeNQT;
        }

        if (builder.signature != null && secretPhrase != null) {
            throw new NxtException.NotValidException("Transaction is already signed");
        } else if (builder.signature != null) {
            this.signature = builder.signature;
        } else if (secretPhrase != null) {
            if (getSenderPublicKey() != null && ! Arrays.equals(senderPublicKey, Crypto.getPublicKey(secretPhrase))) {
                throw new NxtException.NotValidException("Secret phrase doesn't match transaction sender public key");
            }
            signature = Crypto.sign(bytes(), secretPhrase);
            bytes = null;
        } else {
            signature = null;
        }

    }
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:81,代码来源:TransactionImpl.java


注:本文中的nxt.crypto.Crypto.sign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。