Here you can find the source of calculateRx_(BigInteger Rx, BigInteger n)
Parameter | Description |
---|
public static BigInteger calculateRx_(BigInteger Rx, BigInteger n)
//package com.java2s; /**/* w ww . j a v a2 s . c o m*/ Copyright 2014-2015 Center for TeleInFrastruktur (CTIF), Aalborg University Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. @author Bayu Anggorojati [ba@es.aau.dk] Center for TeleInFrastruktur, Aalborg University, Denmark */ import java.math.BigInteger; public class Main { /** * A method to calculate the associate value of an ECPoint R, i.e. Rx_ * @param Rx: the x-coordinate of ECPoint R * @param n: the order of EC base point * @return the associate value of ECPoint R, Rx_ */ public static BigInteger calculateRx_(BigInteger Rx, BigInteger n) { // work around to calculate log of BigInteger value String nStr = n.toString(); int nLen = nStr.length(); nStr = "0." + nStr; double nDoubKoma = Double.parseDouble(nStr); double fDouble = ((double) nLen + Math.log10(nDoubKoma)) / Math.log10(2.0); // ceil of fDouble/2 fDouble = Math.ceil(fDouble / 2); BigInteger coef2 = BigInteger.valueOf(2).pow((int) fDouble); BigInteger Rx_ = Rx.mod(coef2).add(coef2); return Rx_; } }