Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:10:54+00:00 2026-05-23T16:10:54+00:00

Please provide me an example using the Bouncycastle library showing how to add two

  • 0

Please provide me an example using the Bouncycastle library showing how to add two points on an elliptic curve.

I tried the following code but i didn’t get the same result that should happen theoretically.

   X9ECParameters x9=NISTNamedCurves.getByName("P-224");
   ECCurve curve=x9.getCurve();
   ECFieldElement x1=new ECFieldElement.Fp(new BigInteger("10"), new BigInteger("8"));
   ECFieldElement y1=new ECFieldElement.Fp(new BigInteger("10"), new BigInteger("9"));
   ECPoint.Fp p1=new ECPoint.Fp(curve, x1, y1);
   ECFieldElement x2=new ECFieldElement.Fp(new BigInteger("10"), new BigInteger("5"));
   ECFieldElement y2=new ECFieldElement.Fp(new BigInteger("10"), new BigInteger("6"));
   ECPoint.Fp p2=new ECPoint.Fp(curve, x2, y2);
   p2=(ECPoint.Fp) p1.add(p2);
   System.out.println(p2.getX().toBigInteger()+" "+p2.getY().toBigInteger());

And also I didn’t understand what value is to provide for first BigInteger in ECFiledElement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:10:54+00:00Added an answer on May 23, 2026 at 4:10 pm

    Your example makes no sense at all so it is hard to understand what you think the result should be. By using low-level classes like ECFieldElement you are taking full responsibility to provide sensible parameters. You have selected NIST curve P-224. This elliptic curve is defined over a specific field. You can retrieve the prime ‘q’ for this finite field and use it to create field elements by the following (departing from your example):

        X9ECParameters x9 = NISTNamedCurves.getByName("P-224");
        ECCurve.Fp curve = (Fp) x9.getCurve();
        BigInteger q = curve.getQ();
        ECFieldElement x1 = new ECFieldElement.Fp(q, new BigInteger("8"));
        ECFieldElement y1 = new ECFieldElement.Fp(q, new BigInteger("9"));
    

    The first argument of the ECFieldElement.Fp constructor is the prime that defines the field.

    The second problem with your example is that not every pair (x,y) of integers is a point on the elliptic curve. The chance of a random (x,y) being on P-224 is incredibly small. Here again, by messing with the low-level EPoint classes Bouncycastle does not check this for you. So while you can make the machinery of the elliptic curve addition software run and give you answers, those answers are meaningless.

    To make any more progress I have to ask first: what are you trying to do?

    Finding a point on an Elliptic Curve

    There are two basic ways to find a point on an elliptic curve.

    1. take an existing known point on the curve and scalar multiply by an integer. The result is another point on the curve.
    2. Pick an x-coordinate, say x1. Plug it into the right side of the elliptic curve formula to get y12 = E(x1). Then attempt to compute a square root in the field. If the square root exists, then you get two points (x1, y1) and (x1,-y1) that are on the curve. If the square root does not exists, then there is no point on the curve with x-coordinate x1.

    You can get a point on your elliptic curve by ECPoint.Fp = (ECPoint.Fp)x9.getG(); You can multiply that point by an integer with the ECPoint.multiply(...).

    Using method #2 is harder than it needs to be with Bouncycastle. All the methods are in the ECPoint and ECFieldElement classes. The ECFieldElement class contains a public square root method that you can use to attempt to compute the square root. If it returns null then the square root does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you please provide an example of using EnumPrinterData function in Delphi to get
Can someone please provide an example of using set_bound() method from Test::MockObject module? Can
Question: Can anyone please provide a full code example that shows how one does
Can someone please provide an example of creating a Java ArrayList and HashMap on
Is it the same as overloading, if not, can you please provide and example
For example, referencing something as System.Data.Datagrid as opposed to just Datagrid. Please provide examples
Please, provide code examples in a language of your choice. Update : No constraints
Please provide tips for effectively using git with svn. What are your best practices?
If this is possible, please provide a sample query or two so I can
I am using Visual studio in windows for developing C library. Can someone please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.