congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
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

  • Updating database using SQL prepared statement
  • getSharedPreferences (Context)
  • setScale (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JTable (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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