h : {0,1}* → G
This means that h maps a bit string of any length to a point of the the elliptic curve group G.
These sort of functions are quite common in literature and I came up with a quick fix solution for one :-) (and I'm sure there are much better implementations out there).
Here's the code:
import it.unisa.dia.gas.jpbc.Element;
import it.unisa.dia.gas.jpbc.Pairing;
import it.unisa.dia.gas.plaf.jpbc.pairing.CurveParams;
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory;
import java.io.InputStream;
import java.math.BigInteger;
import org.bouncycastle.crypto.digests.SHA256Digest;
public class Digest {
private Element gElem = null;
private Pairing pairing = null;
public Digest() throws Exception {
CurveParams curveParams = new CurveParams();
curveParams.load(Digest.class.getClassLoader().getResourceAsStream("a_181_603.properties"));
//Load private key
InputStream fis = Digest.class.getClassLoader().getResourceAsStream("keys/digest/g");
byte[] tmp = new byte[1024];
int read = fis.read(tmp);
byte[] gBytes = new byte[read];
System.arraycopy(tmp, 0, gBytes, 0, read);
this.pairing = PairingFactory.getPairing(curveParams);
this.gElem = this.pairing.getG1().newElement();
this.gElem.setFromBytes(gBytes);
}
public byte[] createHash(byte[] data) throws Exception {
//Create a sha 256 of the message
SHA256Digest dgst = new SHA256Digest();
dgst.reset();
dgst.update(data, 0, data.length);
int digestSize = dgst.getDigestSize();
byte[] hash = new byte[digestSize];
dgst.doFinal(hash, 0);
BigInteger val = new BigInteger(hash);
BigInteger order = this.pairing.getG1().getOrder();
BigInteger fact = val.mod(order);
Element gen = this.gElem.duplicate();
Element mul = gen.mul(fact);
return mul.toBytes();
}
}
This uses the jPBC library.
16 comments:
Good post. Keep sharing such a new topic.
php training in chennai
Very Interest information. Keep sharing,
Java Training in Chennai | Java Training Institute in Chennai
Thank you for this wonderful post, It really nice and informative. Keep sharing!!
SEO Training in Chennai
JAVA Training in Chennai
Big Data Training in Chennai
Selenium Training in Chennai
German Classes in chennai
Android Course in Chennai
Android Training in Tambaram
excellent blog very nice article I have read the article thanks for it web design company in velachery
very intresting information..
Free Inplant Training Course For ECE Students
INTERNSHIP
INTERNSHIP FOR AERONAUTICAL ENGINERING STUDENTS IN INDIA
INTERNSHIP FOR CSE 3RD YEAR STUDENTS
Free Inplant Training Course for Mechanical Students
INTERNSHIP FOR ECE STUDENTS
INPLANT TRAINING FOR CIVIL
INTERNSHIP AT BSNL
INTERNSHIP FOR 2ND YEAR ECE STUDENTS
INTERNSHIP FOR AERONAUTICAL STUDENTS
very nice post...
foreach loop in node js
ywy cable
javascript integer max value
adder and subtractor using op amp
"c program to find frequency of a word in a string"
on selling an article for rs 1020, a merchant loses 15%. for how much price should he sell the article to gain 12% on it ?
paramatrix interview questions
why you consider yourself suitable for the position applied for
great post....
Inplant Training in Chennai
Iot Internship
Internship in Chennai for CSE
Internship in Chennai
Python Internship in Chennai
Implant Training in Chennai
Android Training in Chennai
R Programming Training in Chennai
Python Internship
Internship in chennai for EEE
very nice information...
Crome://Flags
Python Programming Questions and Answers PDF
Qdxm Sfyn Uioz
How To Hack Whatsapp Account Ethical Hacking
Power Bi Resume
Whatsapp Unblock Software
Tp Link Password Hack
The Simple Interest Earned On a Certain Amount Is Double
A Certain Sum Amounts To RS. 7000 in 2 years and to RS. 8000 in 3 Years. Find The Sum.
Zensoft Aptitude Questions
Excellent works!!!Information's are amazing visit here for more...
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
I read this article. I think You have put a lot of effort to create this article. I appreciate your work.
Visit us for Printing IDs & Accessories.
I had completely gothrow your post and it is full of innovative information.thanks for sharing this.keep it up!!
android training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
This is really informative. Thanks for sharing this with us. Do share more.
Java Training in Chennai
Java Training in Velachery
Java Training inTambaram
Java Training in Porur
Java Training in Omr
Java Training in Annanagar
Such a wonderful article and I feel that it is best to write more on this topic. Thank you so much because i learn a lot of ideas about it. Keep posting...
Software Testing Training in Chennai
Software Testing Training in Velachery
Software Testing Training in Tambaram
Software Testing Training in Porur
Software Testing Training in Omr
Software Testing Training in Annanagar
Thank you for this wonderful post, It really nice and informative. Keep sharing!!
Digital Marketing Training in Chennai
Digital Marketing Training in Velachery
Digital Marketing Training in Tambaram
Digital Marketing Training in Porur
Digital Marketing Training in Omr
Digital MarketingTraining in Annanagar
Harrah's Cherokee Casino Resort - Mapyro
Harrah's Cherokee Casino Resort · Casino Information 대구광역 출장안마 · Gaming · 순천 출장샵 Hotel 원주 출장샵 Rooms. 통영 출장안마 All Rooms · 나주 출장마사지 Casino Rooms. All Salon Suites · Casino Information · Casino Rooms.
Post a Comment