2 * Copyright 2014-2016 the libsecp256k1 contributors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * This class holds the context reference used in native methods
21 * to handle ECDSA operations.
23 public class Secp256k1Context {
24 private static final boolean enabled; //true if the library is loaded
25 private static final long context; //ref to pointer to context obj
27 static { //static initializer
28 boolean isEnabled = true;
31 System.loadLibrary("secp256k1");
32 contextRef = secp256k1_init_context();
33 } catch (UnsatisfiedLinkError e) {
34 System.out.println("UnsatisfiedLinkError: " + e.toString());
41 public static boolean isEnabled() {
45 public static long getContext() {
46 if(!enabled) return -1; //sanity check
50 private static native long secp256k1_init_context();