2012/12/31

To start 2013

As I've recently said, many projects are open. But the job isn't the only source of projects. It's more the bottleneck of my projects. Often is this job requires too many extra-hours under an uncompensable way: the time dedicated as a workers representative.

It looks far from now, but it's not that far, when we've been having enormous problems in this synchrotron. I remember when the corridors were not save, and at any time you can cross someone that screams you in there. As an example: accusing you of sabotage and in the same conversation telling you that you aren't skilful to do whatever you are being accused, but unknowing about what the hell you are being accused. There were a time that this kind of things have happen once at a month or two.

I remember when a Director interrupt in a workers assembly, screaming and saying that workers doesn't have do decide anything. When two days later, a worker has been fired (technically invited to left the company) being a workers advice. In my opinion this has been the trigger (or at least one of the triggers) of what have happen later on.

Event that the situation scares too much, some of the workers have started to self-organise to change this. We where clear that the things on that institution must change radically. Yes, in my opinion, was the old director who generates the situation of its fall (sorry: ascension to direct a Basque spallation source)

Even that, not all the problems have left this excellence installation. Still too far from being a normal laboratory, there are problems that persist. Hindrances of the past that are a burden in the institution, playing the same roles than with the old director.

We have change the direction but still not the heading. I have hope over 2013 that this institution will follow a good heading.

2012/12/20

fpFCT: simulating the bunch current

fpFCT is an smaller name of the Filling Pattern from Fast Current Transformer. As I've said I didn't know how to simulate the signal that is in coming from the scope, and I found a solution.



This is a reused image of the scope signal from the storage ring FCT and what I found how to simulate using PySignalSimulator is:



There are only 4kpoints instead of the 40k that the scope is giving but it looks quite similar.

But how this has been set up in the PySignalSimulator properties? The initial idea was the amplitude modulation but with this what is represented looks like:

But what if the carrier wave, better than a sinusoid looks like a quadratic waveform. With this I have started to play with harmonics. The formula that likes more to be a carrier has been:

In red is plot the carrier over the modulated signal in blue. The signal that is being modulated has been omitted because is almost a sinusoid.

The formula of the carries is:
With parameters values:
The formula of the modulated signal is:

With a_2 = 1; w_2=0.065. The x_2 is a value that is changing from time to time to introduce a drift in the signal in order to have a "dancing" bunches like in the scope. 

Lets see the result:

2012/12/18

Fast Orbit FeedBack

One of the necessary improvements of Alba is the top up system. With this, the beam accumulated in the storage ring can be restored under a continuous re-injection precisely on the buckets here it bunch is losing charge. Recovering an old snapshot of the machine status:


This is an example where the stored beam had decay from 60mA to a bit more than 30 in around 6 hours (this was a year a go, by now we are having more current and a longer beam live time). This lost of current requires re-injections like what is in the middle of the red plot.

This re-injection, afaik, produces perturbations on the beam orbit that at the end means drifts in the x-ray beam in the beamlines. This re-injection, due to radiation safety reason have to be done with the frontends closed. That is with the beamlines in a standby, without light and waiting  that this re-injection finishes. This re-injection causes an interruption on the experiments, and the longest experiment you can do is the one that can be performed between re-injections. You can imagine the consequences if the most insignificant thing fails in the middle of an experiment.under this conditions.

Well, to make this re-injection possible with the frontends open, the orbit of the beam must be very static. The beam has to be thine characterised and its oscillations below some microns.

How the orbit is corrected? In the sextupoles, there are the coils for each of the poles, but it is also another pair of thinner coils that sets the corrector component. I imagine it like a tiny little bending (they have like 3 orders less of magnitude in terms of current).

Those correctors can change its current very fast for a small modifications. That can be, in the order of the hundreds of miliamps can change it with a 10kHz frequency.

With this, together with a beam position monitoring at this speed, and if you can process all this data, the orbit perturbations can be controlled good enough to allow to re-inject with the necessary safeness to implement the top up system and have the plot of the current as an straight horizontal line (negligible ripple).

Main issue: with in a ring of around 400m of perimeter share between 88 beam position monitors all their sets of data, plus the sniffers we have to take this data to calculate those corrections, and stablish the new setpoints to another 88 corrector power supplies. All this at 10kHz: read, calculate, write: simple operations.

Filling Pattern From Fast Current Transformer

As I explain the a previous post we have a Fast Current Transformer in the storage ring and we are able to see the signal in an oscilloscope. Many years a go I have started a project to have the features of those scopes we have in the control system.

It has been started as a Tango Device server in C++ many years a go, but from a refactoring it have changed to be a python device using PyTango. Also this new release have suffered many changes, specially the one that expands this server to more classes to be able to control, not only scopes, but also Spectrum analysers, Signal generators, and later on Radio frequency generators.

But this device have been more used in this "extensions" than in the original scope class. The Signal generator has been used in the booster tune excitation together with the spectrum analyser in the booster tune measurement (I didn't have time to write about those projects here, I hope soon). This devices works fine and the quality was good enough to change the storage tune measurements to be like the booster ones.

Due to Linac's needs to archive some scope measurements, the scope tango class was improved giving as an output here three posts. This was the real trigger that have launched this device server class.

A few weeks a go, more requests have been receiver about scope acquisition: It has been requested to have available the signal from an FCT in the control system, Also this required to improve the acquisition of the waveform from the scope and after some tries help has been requested to the manufacturer. With this I have reduced the network transition of 40kpoints as 300kB to 80kB or 40kB depending on the float precision. This allows to start polling the scope waveform at 3Hz.

This have boosted the project of the Filling Pattern studies using this FCT signal and a device server is available to perform this calculation. Just now that there is no beam, there is no signal in the FCT, only electronic noise like:


)Instead of the usual signal we have when there is beam:


Like often happens I had to ask what this mean and I had try to explain. But, to test the development of the FCT signal analysis, it's necessary to simulate a bit it. No necessary to have the same signal but I should complain that have to change from time to time to have something alive to be analysed.

The solution is to use a simulator of signals, and the best way is using the incredibly versatile PySignalSimulator device server. Creating a device with one property "DynamicAttributes" with something like:
A1=float(READ and VAR('A1') of WRITE and VAR('A1,VALUE)
This sets an scalar attribute with a float value that than be read or write. Combining this with an attribute that contains an array of elements:
Channel1=[ (sin(VAR('W1')*x)*sin(VAR('W2')*x)) for x in range(4096)]
With those simple lines you can have an spectrum value with a amplitude modulated signal. It's not the same than the beam signal, but it can acts to show how this bunch analyser works.

In the next video, the oscilloscope signal has been simulated using this simulator. You will see it  as the top-right blue plot with an amplitude that oscillates between 0 and a maximum. The variables of the formula that simulates this are below this plot, on the left side.


On the left side of the screen some data are revealed about the cpu, memory, network use and so one. After send the Start() command the image below the plot (on its middle) start to collect each one of the waveforms from above. And already with non complete buffer the data is being processed. On the right of this cyclic buffer image representation, there are the attributes to adjust the algorithm and then the output. The green plot on the top is the filtered output.

Projects cross check

Today, we have a blackout in the Alba's synchrotron. From 8h to 15h we have received a recommendation from the director to avoid to go to the facility before 15h. Some intermediate bosses have tell their workers to not come and what ever they want, others say to work from home, and some of them say they don't expect that us comes after 15h. Ok, this is like an almost free day, as usual in this facility, not using clear works and giving different orders to different workers.

Well, when they do this confusion in diffusion (don't confuse with Shannon's principle) I remember Sun Tzu words: “If words of command are not clear and distinct, if orders are not thoroughly understood, then the general is to blame. But, if orders are clear and the soldiers nevertheless disobey, then it is the fault of their officers.

I'll dedicate the day to a projects cross check to have them reviewed, and I'll share them using this blog channel.

Update: Only the Filling Pattern FCT and something about the FOFB, has been possible to write by now. The new plugin to acquire with the Basler Ace Coloured cameras (by now we are using monochrome Basler Scout models in many of the beam diagnostics stations) and the refactoring of the graphical user interface of the imaging acquisitions, are also very important an big project that we need to proceed with. Also this imaging tools must be integrated with in sardana. With out forget the StateCodeInterpreter project, very necessary to trace back what had happen with a power supply.  Another day it will be explained.
And the things wouldn't finish where, there are also projects that have a title but not yet received the Start() command... (like the linac's control & gui).

2012/12/11

About many recent anonymous comments

This blog has been configured with rights to post comments to anyone (including anonymous users), and without moderation level. Even that, blogger is blocking spam comments and they are mailed to be check if they are "no spam". Those comments include links to webshops and that is why I didn't pass them to publish.

The reason on this post is that, since a month a go I see a "peak" of a few comments referencing the type of topics on this blog. At the beginning I didn't care about this, because I write about what I want to write, tagging with labels that an eventual reader can discriminate about the topics (assuming that someone else is reading this blog).

This is not a business blog at all. As the name says, when it was chosen, the main topics are cryptography and synchrotron things. This has been mentioned in the opening post and a bit later when I have broaden my intentions. But I am human, an alive human, and the things changes. This change can be said that starts with the first post tagged as politics. My live is not only my job, and my interests are far away from "live to work", I am more on the "work to live". Work is a need on this society system. Further than contribute to the community (an ideal view of the work), to work by now is a need to have the minimums to still be in this society. Even if you like or not the current organization, you need it to still be.

What is happening by today, specially in the behaviour where I live (that is what I can see with my eyes) is too bad to still be only post about the initial topics of this blog. The life is much wider than businesses.

2012/11/21

How to see the beam in the storage ring

I have written some times about how a synchrotron works (underlining that I am not a physicist and what I write is what I understood from the explanation of other people). Also I have wrote about how can we saw the beam or its effects: visible beamfirst xrays or fluorescent screens

But there is another way to see the beam: using an scope.

Today I have ask to know a little bit more what we can see from an scope that we are reading the signal:
vncviewer of an Agilent DSO80804B
But, 2 questions: who this signal is get and what does this mean?

This signal is get from a Fast Current Transformer (FCT) located in sector 02:

Very close to the dcct that is giving us the current of the beam in the machine statusThis FCT is an inductor surrounding the vacuum chamber and what we see in the scope is the inducted current by the primary current given by the electron bunches.

In the scope picture we can see the bunches in one turn (about 900ns). But a bunch is not one of this eleven groups in the signal. They are composed by bunches.

May can help to see that by plots taken with taurus:
Equivalent to the vnc, but getting the data from a tango device server.

Zooming on one of this groups:

With this last picture we can see the bunches themselves. The bunches are separated by 2ns, and the linac is shutting in groups of 32 consecutive bunches and a gap of 24ns.

Also I have ask why this groups of bunches have different shapes like:
This 3 examples has been taken over different times during today's start up of the machine. This shapes can be explained because fine configuration or how the equipments works and their efficiency. In the best case, in a world of the theory, this groups would be absolutely squared.

Alba synchrotron recovered

Yesterday, after the accident and the weekend works to recover it, we had beam again in the storage ring:

Having beam during more than 2 hours means that, after the accident, nothing have fell down and block the path in the pipe.

2012/11/15

22 arrested versus 29 injured

The original title of this post was 'European Strike 14N' because testerday we had a call for strike in many places in Europe. Some of the European countries doesn't have the right for a general strike (like Germany). In fact the bigger calls was in the south of the continent: Portugal, Malta, Cyprus, and Spain have had a journey strike, in Greece they had a 3 hour call for strike (remember that they have had 2 journeys of strike last 10th). In Italy the call has been made for 4 hour.

But why the today's news have changed my mind? I thing there is a mismatch in the police actions when the injured people in the demonstrations are more than the arrested (worst when the is not intersection between the arrested joint and the injured joint).

Well we have to think that one of the injured is a riot police man that has run over by a police ban:

Another of the incredible videos of the demonstrations is the one that a 13 yeas old kit has been injured in Tarragona:

After watch the video I have hallucinated with the hits on the girl close to where other physically protect the kit. After the girl protest to the riot controller, she have received the shield hit only to be telling something to the police. This girl doesn't look to be a menace to those police men. But after she have received 3 truncheon hits by two different elements of those shielded giants.

News like this ones that gives more injured people than arrested, makes me think that their method is not working because more innocents (because they hasn't been arrested) have been injured, further when they often say that they have identified hundreds of violent persons.

It is also incredible when the police count as injured their riot controllers with wrist pain. Where the origin of this pain is the hit with the truncheon, and they are not counting all the beat by this truncheons. In the case of the people in the protest, you must finish in the hospital with a big damage to be counted in this list.

Alba synchrotron accident

The afternoon of November 13th, the Alba synchrotron has had an accident. As it has been officially mention by an email to all the staff, during the machine start up after a week shutdown, and accident have vent the vacuum in the storage ring.

Having a 3GeV beam with a current of around 100mA some beam studies were on going. It looks that the vertical orbit have suddenly change (+-5mm). The machine protection was off because it was necessary for the works on going and the orbit interlock protection hasn't being triggered to kill the beam. This protection has been design to avoid the beam hits the cavity when the beam goes out of a safe region.



The first indicator of the issue can be saw in the machine status because usually the operation pressure is rounding the 1e-9 mbar (in the Ultra-High Vacuum range) and in the picture taken the evening of that day this pressure is at 6e-2 mbar, where this is medium vacuum.

Even that this pressure value is not in one position, is an average. There where out-gassed sectors and sectors where the pressure has been contained:



In the bottom plot is possible to see where this accident have vent the cavity and where the pressure is very far than UHV. Notice that the scale is logarithmic in this plot, and we have already start work to fix that. When the accident has happen, some sectors have raised up to atmospheric pressure...

Now the machine status informs a little bit about this and is not giving a pressure value:




Update: Current user run cancelled. Due to the vacuum accident, the current 3 week run with beam for users has been cancelled. We hope to get it back up and running as soon as possible.

Update 20121116: We are recovering the vacuum. Yesterday we where at 0.39mbar on average in the storage ring, and today we are at 0.074mbar (on average).

Update 20121117: Yesterday we've been informed that the breakdown was less than can be thought, if it's possible to say like that. As far as I understood, the electron beam haven't hit the vacuum chamber; the damage has come from synchrotron photons have hit flanges downstream some bending magnets, the feebleest element on the path.

The vacuum technicians are working this weekend to speed up as much as possible the recovery of the machine operation. And today, on average we are at 0.0024mbar having only 4 places with pressures in the medium vacuum range (the others are already in UHV).

Update 20121119: Back from the weekend It look like the people that work this free days did an incredible work:
Sector 12 have 2 reading of 2.7e-3mbar, but as is show in the plot, the others are below the 1e-8mbar. Sector 7 looks to be in an incredible good 1e-12mbar...

Update 20121119, afternoon: the machine status gui recovers the pressure value
The Vacuum Controls gui (vacca) is also showing much better look:


2012/10/01

The German miracle

Taking the Spanish media and the international information that arrives to this country, Germany is where they pave our streets with gold. The PIIGS have their economies compared with Germany with the risk premium.

The gods of the markets decides above everything in a politics system that would be named marketcracy. And if the markets decides that a virgin worker must be sacrificed, the politicians, like a high priest does what ever is necessary to obey the god will.

But mass media are also priest on this system. They make up the reality to adapt the collective think to the global order. Lying to the plebs about how the things happens in other places. But some times they made a mistake throwing something that allows to understand.

In Germany, you have an special tax if you belong to a religion. Each church receives depending on the people that follows this religion. Then belong or not to a religion is translated to money for the ecclesiastic hierarchy.

Today, in the news, I have seen that in Germany the Catholic Christian church is denying religious services to the people that decide to save money by refusing to be Catholic. That means you save 8% tax, by refusing to mention your faith to the government. I think before, you must be practitioner to pay that, because if you don't follow the church activities was use less to pay. Then I think the people that is taking this decision are real believers with real money problems.

The plebs in the PIIGS have received the message that in the north, where the things are made in the good way, they work and they like fine. But the reality is different. In this wrong capitalism, where wins are private and loses are publicly shared, all the plebs are suffering to maintain the rich. It's still the save think than always, it's a class conflict. We didn't finish it, it's only one season more.

2012/08/16

DevEncoded and Basler Ace in Taurus

Sometime a go, I have received the request to control a new model of cameras The Basler Ace acA1300-30g{m,c}. Yes both types: monochrome and colour. The most common cameras to look at the beam are the Basler Scout scA1000-30gm and the scA1300-32gm (yes until now we have only supported monochrome cameras in the service of beam diagnostics by imaging.

To take the pictures of this Basler Scout we have used and contribute using the Soleil's device ImgGrabber, and to analyse those taken pictures we have used the ImgBeamAnalyzer (also originally from Solei).

How we look at the images? Long time a go we have start working with Qt and as a result we have used Qub widget from esrf. This widget has been integrated in tau that has been renamed to taurus.

As an example, I have saved hundreds of snapshots of the gui with beam. The latest publish here was to celebrate the first x-ray beam at alba, but I can share much more of those pictures:




But the software we used doesn't support the Ace cameras. There is a newer software that makes deprecated this software and many of the synchrotrons that are using tango are migrating to LImA (Library for Image Acquisition). This is a very powerful software specially focussed in detectors.

This ccds that I'm talking here are not usually "detectors" in a synchrotron sense. They are not the end of the beamline from where the data of the experiment is collected. The most often activity of this cameras is beam diagnostics previous to the experiment to make sure that everything is on the expected place and the shape of the beam have the desired characteristics. Then they are used very often as a live video image in the graphical user interface (gui) from which I have placed images before.

Another situation is during beam commissioning when this cameras are used much more like a detector during a scan using Sardana. On this situation is not that important the image availability during the measurement, the most important this is the beam study of each picture and the statistical characteristics from the beam.

Then we have two very different user cases. In the upgrade to LImA both must be implemented, and yes they already are.

In the LImA Basler device the Ace cameras are already supported and there are some attributes that allows the possibility to have a gui like we have. But what was the problem? This attribute are from the "new" tango data type DevEncoded. Our system didn't support yet this data type and this has been an august development (almost the best month to work, almost every one on holidays and no one is bothering your development).

What make this data type special? This data type can contain almost anything: basically is a list of an string together with a list of bytes, where the string says what and how the things are codified in the list of bytes.

In the case of the LImA's "video_last_image" attribute, the DevEncoded is given as a "VIDEO_IMAGE" format. An issue of this flexibility is the naming, we are starting putting names without a rule and in the future this will be very difficult to unify and harmonise. 

LImA is hosted in a git repository and in the file "applications/tango/LimaCCDs.py" there is a method 'read_video_last_image()' where this "VIDEO_IMAGE" is codified.

Recently this DevEncoded format has been integrated in taurus.

And as we want to see the images using guiqwt who is integrated in taurus using an extension of this software, we have integrated this DevEncoded as a interpretable data from taurus.

The result: we've been able to take and show images from a monochrome Basler ace camera:


Using a fake beam (a image of the beam printed in a paper and placed in front of a ccd) we can check how it behaves with different beam types:


Very glad and satisfied when you see this images. It doesn't look special, but knowing the effort behind that the view is different.

2012/08/13

The Andalusian labourers and the significant differences of sensitivity before the robbery

Following a similar idea than one of my previous posts I have read something on this matter:
"The Andalusian labourers and the significant differences of sensitivity before the robbery"

I like to share here and translate it:
No one like that some one else robs what is ours. The think is like this from immemorial time that the human beings we have occurred to rules and institutions to avoid it and to punish to that do it.
I understand, therefore, the anger of the owners of the supermarkets where a group of Andalusian laborers has removed food. Although the objective is noble, I have already said that to anybody it likes that someone else robbs what is own and I understand him, then, that they have reported to the authorities.
I even understand that these have been mobilized immediately and leaders of some parties have requested quickly that are punished to the guilty. Is what the spokesman of the Popular Party has done in the Congress, Rafael Hernando, who affirmed that he hopes that the deputy of United Left, Juan Manuel Sanchez Gordillo, is denounced by robbery because, according to there is saying, “the laws are had to fulfill and must have exemplary conducts. This form of protests seems to me lamentable and I hope that Justice intervenes in the affair”. 
I already say that it seems normal to me. But what, nevertheless, it does not seem so normal to me it is that these authorities and the politicians who have been scandalized so much by the theft of the laborers are so little sensible to other much more great robberies that happen to newspaper in our country. That is to say, that they have got upset as much by a theft of small account and they do not persecute the great robberies and swindles.
Let us see: 
Let us suppose that the labourers filled each one of the shopping cart with food by value of 300 euros each one (what he would mean, by the way, that the stolen total amount is very small for Carrefour and Mercadona, because between both company they obtained 845 million euros of benefits in 2011, and if we suppose that they gathered 25 cars of food is that with that benefit they would be possible to be filled to 2.8 million cars with food by value of 300 euros each one).
Now let us compare this theft with other three robberies of which they have taken place or they take place day to day in Spain: 
a) Robbery of the electrical companies.
The engineer Antonio Moreno has demonstrated that “every day that happens without the Government approves the official rule that he defines in what consists “the suitable renovation and update of the park of accountants”, the electrical companies receive the following amounts illegally (including the VAT):
- More than 600,000 euros by a service (“the suitable renovation and update of the park of accountants”) that do not given because the Government not yet has defined of what this service consists.
- Between 196,000 and 342,000 euros by the positive error that has 80% of the accountants because they have not been verified periodically because the Government not yet has published the corresponding norm”.
That is to say, that the company electrical (single to receive a service of renovation and update of accountants that does not render) robs every day to the Spaniards equivalent to 2,000 shopping cart with food by value of 300 euros each one, which represents about 730,000 shopping cart after the year.
As it can be seen in the Web of Brown Antonio (http://www.estafaluz.com) if the other concepts of the continuous swindle of these companies are added, it would be that the very many ones are robbing us equivalent to more shopping cart.
b) Robbery of the preferred participations.
As it is known, a good number of banks deceived thousands of Spanish savers placing “preferred participation to them” as if those products were deposits, without informing to them of which in fact those things are something like actions without right to vote and whose single cash could be recovered in very leonine clauses (a news tv report of Tele5 on this subject here).
As a result of that fraud of the banks around a million people there are lost the immense majority of its savings, calculating that those losses, a true robbery, can have a value of between 10,000 and 30,000 million euros.
If we accepted the lowest estimation (10,000 million), it is that the banks have robbed to a million Spanish citizens, and only by the concept of preferred participations, the equivalent to 33 million shopping carts loaded with food by value of 300 euros each one.
c) Fiscal fraud.
According to the technicians of the Ministry of Finance the 72% of the fiscal fraud (that is of about 89,000 million euro altogether), is made by the biggest fortunes and the greatest enterprises corporations, which means that these didn't pay to Finance's Ministry about 64,000 million euros to the year.
If we accepted that to evade the payment of taxes to which we are compelled it is a robbery to the society, it is that the great fortunes and corporations rob to all the Spaniards the equivalent one to 213 million shopping carts loaded with food by value of 300 euros each one.
To these robberies we could add others to great scale, like that the deceived families who contracted with banks credits with fraudulent clauses ground (information here and here), those that practice the pharmaceutical companies (information here), or and endless suffered daily of bad practices of the banks that cost thousands of million to all the Spanish citizens (adicae). Neither mention the global robbery of astronomical amounts of money that the financial crisis has supposed, the banking rescues, etc.
In conclusion: it could seem reasonable to me that it is wanted to persecute and to condemn the labourers who have stolen a few shopping carts of food by value of about 7,500 euros and not on its own benefit. But what I ask myself it is another thing:  how is possible that such judges, public prosecutors, police, authorities… that they are persecuting and that will finish jailing to the labourers responsible by the theft for a few shopping carts of food do not persecute with similar fervor to those who amounts are robbing us that are several million greater times?
I do not know that the readers think but, at sight of this so contradictory behavior and the poor effective persecution who have those multimillionaire robberies, with what I think they criminalize the labourers not because the robbery itself but by another thing worries to them: because to whistle-blower to show the worse and more revolting shame of our opulent world is seen: the hunger. A suffering, do not forget, that the result of the lack of resources is not an accident nor but, as said the previous Relator of the Nations United for the Problems of the Feeding, Jean Ziegler, “a organized crime  against the Humanity”. And he is for that reason, I create, who the criminals who commit it or who help to commit do not want it that he is spoken of it.
So do not be hypocritical: If the authorities that demands the respect to the order and the property were coherent and ended the true thieves who are robbing to the immense majority of the society there would not be more labourers taking eaten of the supermarkets. 

2012/08/10

When there are two laws

Now a days, specially during this crisis, it becomes much more evident that even before the double standard of the law. There is two ways of justice in Spain, and certainly every where else in this world but often they have more precautions, where today is too much evident.

It's not the same punishment for things that are morally equivalently wrong, and the worst is when the punishment depends on your social class. As rich as you are: more impunity you have.


This country is plenty of examples of this. Should be Felix Millet in jail due to a misappropriation of public founds? There are people in jail to have robbed much less, but he is not prisoner. The Catalan health system is also soiled by scandals. And the corruption of this both cases splash too many politician, when at the same time the mass media hides this informations. And even all this things the citizens have to pay an extra € per each medicine prescribed by your doctor of the public health care system. I know people who can not take the medicines because they are too expensive and to buy it they have to eat less.

Scandals of corruption jumps to the news very often in spite of the effort to cover and hide it. Where is the solidarity and equitable redistribution. Every where is the same shit.

And law doesn't act, is absolutely blind in this cases. But in the protests from the citizens in the country, we are criminalized. Even if it is a pacific protest in the street, the can accuse the citizens of resistance to the authority to make possible to punish it with jail in a similar form than if your protest is violent.

By criminalize the actions of the working class, that includes unemployed and retired, when fights for the rights and duties of this society, the problem is not solved at all: it makes it more complicated.

All of us have rights and duties, and I insist all of us. Politicians have also duties and not only their rights. Their actions won't be free of consequences. Often is said that the workers forgets our duties, but don't generalize because is not general. And why the consequences only falls down to the plebs? Many politicians and rich forgets their duty to obey the law.

But what they are doing is to change the law in order to have their own full permission to do what they like. That is not the way. Well is a way, but is not the way to live together peacefully.

2012/08/08

Refactoring

The software has its live cycle during which the development and bug fixing are link to several variables, some under control or the developer but many are out of this control. I'm not talking much about the time dedicated to the development during a project, but too. Those variables are out of control specially in the bug fixing time, when the speed and extreme programming are more present.

When some day, some how, some one decides that something is urgent, or more urgent than the other urgent things. At that time, the development will done because of an heroic effort and all bugs will be fixed fast (hopping that the bug fix will not produce any other side effect).

How old must be a code to consider refactoring? It could depend on the number of requirements coming from the heaven. I mean when the number of times that some one is very urgent to codify, the developer does it, but with a price. And this price is a quality loss, until it becomes untenable. When any bug fix requires longer and longer time due to the side effects of the modification.

But there is a moment, that triggers an alert for the project manager that says refactoring is mandatory: when the design have almost nothing in common with the code: when code smell.

Then I found a book that looks nice for this task: "Refactoring: Improving the Design of Existing Code" Fowler, Martin (1999). More than ten years old book, older than the code I want to refactor, live irony.

2012/08/06

Generalized Rijndael, schematics

Before to enter in deep on the questions remarked in the previous post about this series, I like to post some schemas that some day would be useful.

The Rijndael symmetric cryptosystem build by iteration using a network of permutations who follows the basic shannon's properties of "confusion and diffusion". The bits in the plain text are mixes and substituted by a group of operations do by an order. To decrypt, what have to be done is to do the same things but in the opposite way. For sure, there is a key to introduce here the secret to be able to undo the encrypt operation.
Diagram 1: Flow of the Rindael encrypt/decrypt

As in the diagram 1 shows, using only 4 operations (subBytes, shitfRows, mixcolumns, addRoundKey, and its inverses). But those operations are in a certain order to maintain a set of properties.

  • subBytes: word substitution, where each element in the state matrix is replaced by its inverse and an affine mapping. Operations in
  • shiftRows: cyclic left shift of the elements of the i'th row by i words.
  • mixColumns: column linear transformation of the state matrix, where each column is given as an element of a polynomial ring, where the coefficients of this polynomial are polynomials in .
    This polynomial ring is: 
  • addRoundKey: XORed transformation between the state matrix and the round key.

Is necessary to emphasize the use of a part of the key in the 'addRoundKey()' operation. This round key is much longer than the given key to encrypt/decrypt, and the process to generate this key expansion can be described in a iterative way:


Diagram 2: Iterator schema of the Rijndael key expansion
The first 4x4 matrix (the ) is the original key given with in a structure of a matrix of elements in the wordsize (8 bits, a byte in rijndael, AES). This example is using the 128 key option but the key matrix can have more columns: To build the key expansion its the same way, but remark that "#c" represents the number of columns for the message, not the key.

To build the following columns to have each round keys, an iterator is good to see how this is made. I have tried to get an schema from other webs sites, but the ones that I found haven't convinced to me. I hope this would help to someone who search on internet for a diagram of the rijndael key expansion.

2012/08/02

RFC 6637 and construct elliptic curves

A new request for comments is available for elliptic curve cryptography. With the number 6637 the past June 11th was announced as official. Very good news for the elliptic curves and its cryptographic implementations. 


From the first version of this standard when it was a candidate has passed a few months more than 4 years. Yes, more than 4 years to public discussion. Necessary for consensus in standard development, but much more necessary for cryptography.


The old project of the patch for GnuPG, who was already obsolete a long a go, have some relation with the final code in the GnuPG. I'm glad when I see it in the sources that I have contributed somehow.


But what about the supported curves? The mentioned standard restricts the use of only a very few of them. The supported curves are only 3, one per each supported size: from the fips 186-3 the p-256p-384 and p-521 (the biggest 3 of the 5 in the Appendix D.1.2 "Curves over Prime Fields). They are known as the NIST curves and they are from the NSA suite b.


Yes, the standard doesn't close completely the use of other curves. There is a field in the structure of the key to specify the curve, but is not set directly the curve. What is place in the field is the curve OID. Even if the number of curves that can be listed using this Object Identifiers can be very big, it will never be as big as the existing and cryptographically valid elliptic curves. But there is hope in this issue, it wasn't like that the full time of this pre-standard process, there is a octet, the first one, who have a reserved value (0xFF) for future extensions.


Why can be so important to use as many curves as the users want? Easy, one of the biggest features in elliptic curves is the possibility to change the cyclic group where the discrete logarithm is protecting your secrets, without changing the size is because using a different curve with in the same base finite field the hardness of move an attack from the cyclic group in one curve to another cyclic group in another will be almost equivalent to start from scratch the attack over the new cyclic group on the new curve over the same finite field.


But, how can be a new curve generated? Recently in arxiv I've seen a article about this matter: "Method for constructing elliptic curves using complex multiplication and its optimizations" (July 30, 2012).


I've been working in isogenies using volcanoes and stars of them to speed up the initial way to construct a new curve (pointed in the abstract of the cited article):


  1. , where and
  2. If it doesn't satisfy the conditions restart from 1
But this article proposes the other way around, start finding an order that satisfy the conditions and then build a curve of this order. It's a promising idea to have a nice way to have as many curves as necessary. 


With the isogenies, I didn't found how to speed this up enough to have a new (cryptographically good) curve during the key generation (a reasonable time to not desperate the user). And even more, having the possibility to reset your key by change and old curve by a new one with out needing to create a new key, but assuring the security by a public and auditable procedure.

What is the utility of this feature of the cryptosystem reset? One that I can imagine, and can be compatible with the current standard is to have a corporative elliptic curve in the smart cards and periodically renew the curve. Knowing the path in the isogeny star, all the smart cards would be able to "migrate", but for a cryptoanalyser will be a very enormous hard work to "port" any running attack, even if the public keys are available in both curves, from the origin to the current if the path is still secret.

The most important thing in cryptology is the trust on mathematics. Giving the user 3 curves, that looks good, but only 3, is not enough. Like the S-boxes in DES, that wakes up susceptibilities, specially at the beginning, to know how they had been build (why those and not any other). Even more, giving a list of hundreds of thousands curves is neither enough because the problem is still the same.

The unique solution I see on that issue, is to give this public and auditable algorithm that allows the community to validate (or break) it that make the user confortable with the provided security.