bitcoin-s-key-manager_2.11 0.3.0 javadoc (org.bitcoin-s)

How to verify a signed message in bitcoinj?

Link to bitcoin stack exchange: https://bitcoin.stackexchange.com/questions/92406/how-to-verify-a-signed-message-in-bitcoinj

I want to verify, in Java, a signature produced with bitcoin core's signmessagewithprivkey (equivalent to the verifymessage). I noticed a bitcoinj method similar to the bitcoin core's verifymessage - org.bitcoinj.core.ECKey.verify. What follows is my implementation attempt and its test.
For testing I will generate a signature and check it in bitcoin core:
>bitcoin-cli signmessagewithprivkey $(bitcoin-cli dumpprivkey 1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp) "" H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic= > bitcoin-cli verifymessage "1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp" "H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=" "" true 
So, signing an empty message with the RPC using the address 1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp (public key: 021c3be5fb7820c56d881ea2d02a906d87540ec8888bbe819b7abd2e39f6f6e512), produces the signature H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=.
My Java implementation attempt:
import org.apache.commons.codec.binary.Hex; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.Sha256Hash; import java.math.BigInteger; import java.util.Base64; public class Notebook { public static BigInteger[] ParseSig(byte[] sigBytes, int sigOff) { BigInteger r = new BigInteger( 1 ,sigBytes, sigOff, 32); BigInteger s = new BigInteger( 1, sigBytes, sigOff + 32, 32); return new BigInteger[] { r, s }; } public static void main(String[] args) throws Exception{ // Signature String signatureString = "H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic="; byte[] signatureBytes = Base64.getDecoder().decode(signatureString); BigInteger[] signatureRandS = ParseSig(signatureBytes, 1); ECKey.ECDSASignature signature = new ECKey.ECDSASignature(signatureRandS[0], signatureRandS[1]); // Public key String pubKeyString = "021c3be5fb7820c56d881ea2d02a906d87540ec8888bbe819b7abd2e39f6f6e512"; byte[] decodedPubKeyString = Hex.decodeHex(pubKeyString.toCharArray()); ECKey publicKey = ECKey.fromPublicOnly(decodedPubKeyString); // Message String message = "Bitcoin Signed Message:\n"; Sha256Hash messageHash = Sha256Hash.of(message.getBytes()); Sha256Hash messageDoubleHash = Sha256Hash.of(messageHash.getBytes()); // Test boolean result = publicKey.verify(messageDoubleHash, signature); System.out.println("Result: " + result); } } 
Notice that I used the salt Bitcoin Signed Message:\n before hashing the message - this is done by signmessagewithprivkey as shown here and here. The problem is the above implementation doesn't pass my test and I don't know why...
submitted by johnturtle to BitcoinBeginners [link] [comments]

A few thoughts - Wednesday, July 23, 2014

Good evening! A few thoughts for dinner tonight:

Life is about economics

Many people don't place enough emphasis on economics when making decisions about their lives, instead making incorrect decisions based entirely upon emotions. Economics, which is the study of how scarce resources are allocated, affects anything of value that often seems to have little to do with what most people consider to be money.
There are some people who repeat trite sayings like "life isn't all about money." In fact, life is all about money, as anyone who doesn't have any can attest. You don't have to spend your money on cars or houses to participate in economics. You can also trade money for other things like years of life, time off, avoiding prison, and so on. One of the more interesting economic theories links abortion, money, and crime, on the theory that people with little money don't spend enough time with their kids to instill positive values in them, and therefore allowing abortions in 1973 resulted in a reduction in crime in the 90s when those kids never grew up.
On Monday, I talked about the idea that some people will ignore the regulations in New York because they are willing to take the risk of prison in exchange for money. Shortsighted people may look at such a trade and reply that any amount of money isn't worth a year in jail, but the best way to look at this is to take something you want, or don't want to do but need to, and replace it directly instead of using money as an intermediary. This is called the transitive property in mathematics: it states that if "A=B and B=C," then "A=c." Now replace the variables. If you could guarantee that one year in jail earned you one million dollars, and one million dollars was enough money to avoid working for 25 years, then one year of jail is worth 25 years of non-work. When you take out the money from the equation, you get the same result but it is easier to see how economics causes people to do what they do.
Consider some other examples. Someone who spends 1/4 of his or her time partying in college (1 year) gets lower grades and can't get a job for 6 months after graduation, whereas not partying at all results in getting a job the day after graduation. If the new engineer makes $50,000/yr, that means that the partier makes $25,000 less over the course of his lifetime. But that's not all, because that $25,000 will compound in interest over time (on average, the stock market will double every 12 years). Therefore, if someone graduating today can expect to work until age 80 (or 60 years), then that $25,000 put into stocks will be worth $800,000 at retirement. If one year of a comfortable lifestyle costs about $50,000, then we can take the money out of the equation and conclude that partying for one year in college has a price of 20 years of retirement.
Finally, let's consider the example of terrorism. Those airport X-ray scanners cost $90m and the risk of death due to terrorism is about 20m:1. It costs about the same amount to research a new cancer drug. The risk of dying of cancer is about 5:1. Therefore, if the drug is effective in 1 in 4m people, then it would have been a better investment than the X-ray scanners. Most drug studies express the results in terms of how many of the treated patients got better compared to the control patients who were untreated. In percentage terms, the effectiveness of the drug would have to be 0.000025% for it to be a better deal. These odds assume that if the machines were removed, then the risk of a terrorist attack would at least double, which is doubtful. In fact, if every person who ever developed cancer in the past 80 years were treated with this drug, only 375 of those billions would have to be cured for it to make sense to ditch the airport screeners.
The conclusion here is that if you want to make the best decisions for your life, you need to recognize that everything, even life and death, can be reduced to money. In a perfect world, there would be some things that are priceless, but this is a world where things are scarce and people suffer and die all the time. Money isn't just a concept that determines how much stuff you can buy; it places value on things like time, health, and freedom that can, like other goods, be risked and traded for other things of value.

Transaction volume not rising quickly enough

Some have tried to argue that the low transaction volume recently is fine because it is not falling. I disagree because in technology, you are either innovating or you are dying. Software is either in development, or it is abandoned and nobody wants to use it. In business, your company is either growing or it has headed towards a decline. There are no steady states in these industries.
In order for bitcoins to succeed, the transaction volume not only needs to be growing, but it needs to be growing very quickly. If you draw a line through the transaction volume chart and look at its slope, you can extrapolate growth to approach the same level as MasterCard around... when? 2100? Obviously, the world will be a different place then and something else will have grown faster than bitcoin by that point (or people will have just given up on the technology).
While past growth might seem like it is unprecedented, it is exactly what we would expect to see for a new technology that would achieve mass adoption in 5 or 10 years. If that growth slows down to, say, 1/3 of its previous level, then mass adoption would be expected to take as long as 30 years, which is unreasonable. With the world changing at an accelerated pace, a 30-year adoption cycle is not realistic anymore for any technology regardless of area of life.
If bitcoins are to succeed, the growth needs to continue at a rate similar to the past. While many traders would be happy with 50% returns per year, that sort of growth simply can't support the technology. When I suggest that the transaction volume is a danger sign, the volume doesn't have to go down in order to be a problem. It simply has to stop increasing at the rate necessary for bitcoin to break out and become the dominant force in the economy.

Configuration is much harder than development

Over the past few days, I've been struck by something that I knew all along, but was not aware of how important it is to recognize. In developing an engineering system, configuring other people's software is far more difficult than writing your own is. In fact, if what the other software is doing is simple enough, I'm now convinced that it makes more sense to completely rewrite it, because you'll gain a better understanding of the problem and probably come out with a better-written solution.
Right now, our pool has complete software that has no known bugs. We want to release it for testing so that additional bugs can be found and fixed. One would think that if someone gave you the code for a complete system and told you to set it up and start making money, you could do that in a few days. Consider what seems like a simple problem: setting up a router. You pay $200 to a company like Cisco only to find out that their router freezes when it has more than 30 port forwarding rules applied. They list this as a "known issue" that can only be solved with a reboot at the remote location, a procedure that takes hours. Surely the biggest networking company in the world can afford to release a firmware update that allocates a few kilobytes of memory to host more port forwarding rules.
Other examples of this problem are Cryptsy's API, where their customer service released a bug that broke the entire system for 12 hours, "pusher," a service that receives data from remote sites but does not reconnect upon disconnection as it promises to, CGMiner, which requires that bandwidth-wasting duplicate data be sent to the client every 30 seconds or else it disconnects with an error message stating that the connection was interrupted, EFI, which is a million-line operating system that runs underneath Windows and Linux and which is a patchwork of thrown-together code from so-called "professional" companies, and the bitcoin daemon, which until recently simply didn't compile under Debian.
Finally, many people fail to recognize how important documentation is to software. Without documentation, nobody else can use the software, period. In the case of APIs and developer-centric software, a function that is undocumented is as good as useless. There are some javadocs out there that have functions like "sendmoney" with the default description. How do you even begin to know what that does, and would you trust calling such a function blind?
So many products have so many issues that a good rule of thumb is that if you can rewrite whatever the other software is doing in one weekend or less, then it is probably worth the effort to just rewrite it. Code quality is a serious issue in the bitcoin community. In addition to criticizing the lack of development of the core software, we should also be drawing attention to the issue of how much of the surrounding code is often unusable.

Other

submitted by quintin3265 to BitcoinThoughts [link] [comments]

[Hiring] Java Callable Needed (XChange Library/Bitcoin Exchange API Work)

I have a trading program that I'm working on. I'm looking for someone to build a component of this program in the form of a Callable. The rest of the program uses the XChange library, so this component must be implemented with the XChange library as well.
The job of this component is to submit an an active limit order to a Bitcoin exchange via XChange. This order is intended to execute immediately and not sit on the order book. Interacting with a live financial market over the internet is a dicey proposition, so if things don't go to plan this component needs to deal with the things that can predictably go wrong.
An outline of how this component should work is below. Note terms in italics are meant to reference objects from the XChange library. These objects can be reviewed at XChange's Javadoc. I would reference you to the objects within the javadoc if I was able to, but alas that is not the case.
-The Callable has a constructor that passes to it a LimitOrder and Exchange. Don't worry about what those are or if they are set up properly, that is the responsibility of the wider program that you are working within. Use dummy LimitOrder and Exchange parameters during construction and testing of your component.
-Using a PollingTradeService created from the Exchange passed in via the constructor, attempt submission of the LimitOrder passed in via the constructor. I suggest keeping track of the orderID that is returned, you will probably need it later.
-Throw any exceptions you receive from the submission attempt at this stage back to the caller.
-If the submission attempt succeeds in reaching the exchange, wait X milliseconds before proceeding in your thread. X is a configurable variable that will be set to a range between 2000 and 10000 milliseconds. This period gives the exchange time to process the order, it also gives the market a brief period of time to react to this order. Throw an InterruptedException back to the caller if this waiting period is interrupted.
-After the waiting period is over, try to cancel the order via PollingTradeService's cancellation methods. If you encounter errors or exceptions, try to cancel it again at least three times before throwing errors back to the caller. It is important we try out best to cancel orders that didn't complete within our waiting period.
-It is now the responsibility of your component to report back to the caller what happened with the order. If it completed fully, calculate the weighted average of the price. If it completed partially, calculate the weighted average of the price, and also return how much did not complete. If it didn't complete at all, return something for that case as well. Feel free to use custom data types objects you create to assist you in this task.
-Test this component against the following live bitcoin exchanges (Bitstamp, BTC-e, Bitfinex).
-After the component passes testing, send me the text of your classes by whatever method you think is best, provided it is not going to put me at a security risk.
-Feel free to use any common libraries that will help you accomplish this task.
These instructions are not going to be perfect. Please ask questions about them publicly in this thread so other people with the same question can read my reply. If you have suggestions on how I can improve my communication, I welcome them.
If you are interested, submit to me an offer via PM for how much you would like to be paid to complete this project, and how long it will take you to complete. Also include a brief paragraph explaining relevant experience you have doing this kind of work. References to portfolio pieces or code in a repository you wrote are also important. Show me why you have the skills to build this.
I will be taking offers for the job over the next ~24 hours. If you get the job I will notify you at the end of this 24 hour period. Given the increase in scams lately I think it is best to do business via the escrow system I've done business with a number of people here on jobs4bitcoins and also bitcointalk.
submitted by wtfSurprise to Jobs4Bitcoins [link] [comments]

MultiBit, Java Bitcoin client Bitcoin.com - Official Channel - YouTube HowTo Send a Bitcoin Transaction with JavaScript & Bitcore ... How to Mine Bitcoins Using Your Own Computer - YouTube Java Bitcoin Generator 2019 CoolPack , generate All BTC Keys Offline

bitcoinj 0.11.2 API. Packages ; Package Description; com.google.bitcoin.core : com.google.bitcoin.crypto Javadoc was added by wenzx in Apr 2010 and the latest update was made in Sep 2020. The list of alternatives was updated Jul 2020. It's possible to update the information on Javadoc or report it as discontinued, duplicated or spam. High level protocols that build on top of Bitcoin go here: we have the payment protocol for sending transactions from sender to receiver with metadata, and a micropayment channels implementation. org.bitcoinj.protocols.channels: Micropayment channels allow for rapid tiny payments to be made to a third party once a channel has been set up, using some of the advanced features of the Bitcoin ... ECKey also provides access to Bitcoin Core compatible text message signing, as accessible via the UI or JSON-RPC. This is slightly different to signing raw bytes - if you want to sign your own data and it won't be exposed as text to people, you don't want to use this. If in doubt, ask on the mailing list. The ECDSA algorithm supports key recovery in which a signature plus a couple of ... JavaBitcoin is a bitcoin client node written in Java. It supports receiving and relaying blocks and transactions but does not support bitcoin mining. This ensure that running this node won't cause a block chain fork. It also support Simple Payment Verification (SPV) clients such as the Android Wallet and MultiBit.

[index] [42797] [31913] [36388] [36634] [18602] [30381] [4246] [25565] [26183] [21656]

MultiBit, Java Bitcoin client

#bitcoin #bitcoinmining #bitcoinminingsoftware By Far The BEST Bitcoin Mining Software In 2020 (Profitable). This is a review on the most profitable, easy, a... Months ago, I tried to learn a bit about Bitcoin, tried a few programs, mutlibit [1] is only one that I could barely accept. Some are way too complicated. Th... http://bit.ly/bitcoincourse (full course) This will demo creating a Bitcoin address and transaction using JavaScript and the Bitcore.io library. Full source ... Start trading Bitcoin and cryptocurrency here: http://bit.ly/2Vptr2X IMPORTANT!! This method only illustrates how mining works. You will not make any money f... In this video we will see: - What is BlockChain - Why blockchain is important - Who is Satoshi Nakamoto - What is bitcoin - Bitcoin with blockchain - Securit...

#