use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.
the class AbstractTransactionMapper method mapTransaction.
private D mapTransaction(Transaction transaction, boolean embedded) {
TransactionDTO dto = new TransactionDTO();
dto.setSignerPublicKey(transaction.getSigner().map(PublicAccount::getPublicKey).map(PublicKey::toHex).orElse(null));
dto.setVersion(transaction.getVersion());
dto.setNetwork(NetworkTypeEnum.fromValue(transaction.getNetworkType().getValue()));
dto.setType(transaction.getType().getValue());
if (!embedded) {
dto.setSize(transaction.getSize());
dto.setMaxFee(transaction.getMaxFee());
dto.setDeadline(transaction.getDeadline().toBigInteger());
dto.setSignature(transaction.getSignature().orElse(null));
}
D specificDto = getJsonHelper().parse(getJsonHelper().print(dto), transactionDtoClass);
copyToDto((T) transaction, specificDto);
return specificDto;
}
use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.
the class VrfKeyLinkTransactionMapper method createFactory.
@Override
protected TransactionFactory<VrfKeyLinkTransaction> createFactory(NetworkType networkType, Deadline deadline, VrfKeyLinkTransactionDTO transaction) {
PublicKey linkedPublicKey = PublicKey.fromHexString(transaction.getLinkedPublicKey());
LinkAction linkAction = LinkAction.rawValueOf(transaction.getLinkAction().getValue());
return VrfKeyLinkTransactionFactory.create(networkType, deadline, linkedPublicKey, linkAction);
}
use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.
the class VrfKeyLinkTransactionIntegrationTest method basicAnnounce.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void basicAnnounce(RepositoryType type) {
Account account = config().getNemesisAccount2();
PublicKey linkedPublicKey = PublicKey.fromHexString("F5D0AAD909CFBC810A3F888C33C57A9051AE1A59D1CDA872A8B90BCA7EF2D34A");
VrfKeyLinkTransaction linkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.LINK).maxFee(maxFee).build();
announceAndValidate(type, account, linkTransaction);
VrfKeyLinkTransaction unlinkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.UNLINK).maxFee(maxFee).build();
announceAndValidate(type, account, unlinkTransaction);
}
use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.
the class Ed25519KeyGenerator method derivePublicKey.
@Override
public PublicKey derivePublicKey(final PrivateKey privateKey) {
final Ed25519EncodedFieldElement a = Ed25519Utils.prepareForScalarMultiply(privateKey);
// a * base point is the public key.
final Ed25519GroupElement pubKey = Ed25519Group.BASE_POINT.scalarMultiply(a);
// a suitable table of group elements.
return new PublicKey(pubKey.encode().getRaw());
}
Aggregations