Tabnine Logo
SECNamedCurves.getByName
Code IndexAdd Tabnine to your IDE (free)

How to use
getByName
method
in
org.spongycastle.asn1.sec.SECNamedCurves

Best Java code snippets using org.spongycastle.asn1.sec.SECNamedCurves.getByName (Showing top 8 results out of 315)

origin: com.google/bitcoinj

/**
 * Output this ECKey as an ASN.1 encoded private key, as understood by OpenSSL or used by the BitCoin reference
 * implementation in its wallet storage format.
 */
public byte[] toASN1() {
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(400);
    // ASN1_SEQUENCE(EC_PRIVATEKEY) = {
    //   ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG),
    //   ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING),
    //   ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0),
    //   ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1)
    // } ASN1_SEQUENCE_END(EC_PRIVATEKEY)
    DERSequenceGenerator seq = new DERSequenceGenerator(baos);
    seq.addObject(new ASN1Integer(1)); // version
    seq.addObject(new DEROctetString(priv.toByteArray()));
    seq.addObject(new DERTaggedObject(0, SECNamedCurves.getByName("secp256k1").toASN1Primitive()));
    seq.addObject(new DERTaggedObject(1, new DERBitString(getPubKey())));
    seq.close();
    return baos.toByteArray();
  } catch (IOException e) {
    throw new RuntimeException(e);  // Cannot happen, writing to memory stream.
  }
}
origin: com.madgag/sc-light-jdk15on

  static ECDomainParameters getECParameters(int namedCurve)
  {
    int index = namedCurve - 1;
    if (index < 0 || index >= curveNames.length)
    {
      return null;
    }

    String curveName = curveNames[index];

    // Lazily created the first time a particular curve is accessed
    X9ECParameters ecP = SECNamedCurves.getByName(curveName);

    if (ecP == null)
    {
      return null;
    }

    // It's a bit inefficient to do this conversion every time
    return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(),
      ecP.getSeed());
  }
}
origin: com.madgag.spongycastle/core

ecP = SECNamedCurves.getByName(name);
origin: com.madgag.spongycastle/prov

public static X9ECParameters getNamedCurveByName(
  String curveName)
{
  X9ECParameters params = CustomNamedCurves.getByName(curveName);
  if (params == null)
  {
    params = X962NamedCurves.getByName(curveName);
    if (params == null)
    {
      params = SECNamedCurves.getByName(curveName);
    }
    if (params == null)
    {
      params = NISTNamedCurves.getByName(curveName);
    }
    if (params == null)
    {
      params = TeleTrusTNamedCurves.getByName(curveName);
    }
    if (params == null)
    {
      params = ANSSINamedCurves.getByName(curveName);
    }
    if (params == null)
    {
      params = GMNamedCurves.getByName(curveName);
    }
  }
  return params;
}
origin: blockcypher/java-client

X9ECParameters params = SECNamedCurves.getByName("secp256k1");
ECDomainParameters CURVE = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
BigInteger HALF_CURVE_ORDER = params.getN().shiftRight(1);
origin: QuincySx/BlockchainWallet-Crypto

  public static boolean verify(byte[] publicKey, byte[] signature, byte[] msg) {
    X9ECParameters params = SECNamedCurves.getByName("secp256k1");
    ECDomainParameters EC_PARAMS = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
    synchronized (EC_PARAMS) {
      boolean valid;
      ECDSASigner signerVer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));
      try {
        ECPublicKeyParameters pubKey = new ECPublicKeyParameters(EC_PARAMS.getCurve().decodePoint(publicKey), EC_PARAMS);
        signerVer.init(false, pubKey);
        ASN1InputStream derSigStream = new ASN1InputStream(signature);
        DLSequence seq = (DLSequence) derSigStream.readObject();
        BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
        BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
        derSigStream.close();
        valid = signerVer.verifySignature(msg, r, s);
      } catch (IOException e) {
        throw new RuntimeException();
      }
      return valid;
    }
  }
}
origin: com.madgag/scprov-jdk15on

ecP = SECNamedCurves.getByName(name);
if (ecP == null)
origin: com.madgag/scprov-jdk15on

if (ecP == null)
  ecP = SECNamedCurves.getByName(curveName);
  if (ecP == null)
org.spongycastle.asn1.secSECNamedCurvesgetByName

Popular methods of SECNamedCurves

  • getByOID
    return the X9ECParameters object for the named curve represented by the passed in object identifier.
  • getName
    return the named curve name represented by the given object identifier.
  • getOID
    return the object identifier signified by the passed in name. Null if there is no object identifier
  • getNames
    returns an enumeration containing the name strings for curves contained in this structure.

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now