Search in sources :

Example 16 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project attestation by TokenScript.

the class Attestation method setSmartcontracts.

// TODO change to list of arrays of 20 bytes
public void setSmartcontracts(List<Long> smartcontracts) {
    ASN1EncodableVector seq = new ASN1EncodableVector();
    for (long current : smartcontracts) {
        seq.add(new ASN1Integer(current));
    }
    this.smartcontracts = new DERSequence(seq);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer)

Example 17 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project attestation by TokenScript.

the class AttestationRequest method getDerEncoding.

@Override
public byte[] getDerEncoding() {
    try {
        ASN1EncodableVector res = new ASN1EncodableVector();
        res.add(new ASN1Integer(type.ordinal()));
        res.add(ASN1Primitive.fromByteArray(pok.getDerEncoding()));
        return new DERSequence(res).getEncoded();
    } catch (IOException e) {
        throw ExceptionUtil.makeRuntimeException(logger, "Could not encode asn1", e);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) IOException(java.io.IOException)

Example 18 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project attestation by TokenScript.

the class ERC721Token method getTokenVector.

public ASN1EncodableVector getTokenVector() {
    ASN1EncodableVector data = new ASN1EncodableVector();
    data.add(new DEROctetString(Numeric.hexStringToByteArray(address)));
    data.add(new DEROctetString(tokenId.toByteArray()));
    return data;
}
Also used : ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DEROctetString(org.bouncycastle.asn1.DEROctetString)

Example 19 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project attestation by TokenScript.

the class FullProofOfExponent method makeEncoding.

private byte[] makeEncoding(ECPoint riddle, ECPoint tPoint, BigInteger challenge, byte[] unpredictableNumber) {
    try {
        ASN1EncodableVector res = new ASN1EncodableVector();
        res.add(new DEROctetString(riddle.getEncoded(false)));
        res.add(new DEROctetString(challenge.toByteArray()));
        res.add(new DEROctetString(tPoint.getEncoded(false)));
        res.add(new DEROctetString(unpredictableNumber));
        return new DERSequence(res).getEncoded();
    } catch (IOException e) {
        throw ExceptionUtil.makeRuntimeException(logger, "Could not encode asn1", e);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) IOException(java.io.IOException) DEROctetString(org.bouncycastle.asn1.DEROctetString)

Example 20 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project attestation by TokenScript.

the class Cheque method encodeSignedCheque.

private byte[] encodeSignedCheque(ASN1Sequence cheque, byte[] signature, AsymmetricKeyParameter publicKey) throws IOException {
    ASN1EncodableVector signedCheque = new ASN1EncodableVector();
    signedCheque.add(cheque);
    SubjectPublicKeyInfo spki = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey);
    signedCheque.add(spki.getPublicKeyData());
    signedCheque.add(new DERBitString(signature));
    return new DERSequence(signedCheque).getEncoded();
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERBitString(org.bouncycastle.asn1.DERBitString) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)391 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)330 DERSequence (org.bouncycastle.asn1.DERSequence)318 DERSequence (com.github.zhenwei.core.asn1.DERSequence)286 IOException (java.io.IOException)104 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)91 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)70 DEROctetString (org.bouncycastle.asn1.DEROctetString)70 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)68 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)57 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)49 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)49 X509Certificate (java.security.cert.X509Certificate)40 BigInteger (java.math.BigInteger)38 DERBitString (org.bouncycastle.asn1.DERBitString)35 DERSet (org.bouncycastle.asn1.DERSet)34 Enumeration (java.util.Enumeration)31 ArrayList (java.util.ArrayList)30 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)28 Iterator (java.util.Iterator)26